MVC :: MVC Routing Options A Single Route?
Jul 30, 2010
I am building a forum based application and was wondering if I had to create a different route for each of the following scenarios: View Forums, View Topics, View Posts, Reply to Topic etc... Is there a single route that I can customize to catch all of these for the folllowing urls?
http://www.samplesite.com/forums
http://www.samplesite.com/forums/{forumID}
http://www.samplesite.com/forums/{forumID}/{topicID}
[code]...
Is there a custom route I can make to catch all of these instead of making a different route for each one?
View 1 Replies
Similar Messages:
May 19, 2010
i'm new to routing in aspnet mvc.. i have following code:
[code]....
when i enter "localhost/school" in addressbar, it is giving 404 error instead it should route to my "schoolIndex" action
i have given route-name as "School" where it is used ?
View 1 Replies
Feb 18, 2011
I am building an application in Asp.Net 4.0 (Web Forms). I have used the feature of Routing introduced in this version of Asp.Net (4.0).
I have a few routes declared in my global.asax file. My problem is as long as the number of parameters (placeholders) declared in the route are different the right route is selected. But the moment the number of parameters (placeholders) declared in the route are same there is a clash and the Routing engine selects the wrong route. The only way I found was to use a Constant with one of the clashing routes to distinguish between the two. But I am sure there is a way out of it; I also tried using Regular Expression but still it selects the wrong route.
[Code]....
The last two routes have the same number of parameters so I tried to separate the second last route by adding a regular expression, but in vain.
View 19 Replies
Sep 6, 2010
i How can make the asp.net routing engine ignore routes with an extension of the type /pathtofile/filename.aspx/morepaths
I know this is hardly a real scenario but I need to know for another similar issue for an autogenerated url
View 1 Replies
Feb 8, 2011
I'm attempting to find a way to preventing a user from accessing a specific xml file. I've tried doing...
route "SiteMap",
"SiteMap/siteMap.xml",
new { },
new { isLocal = new LocalHostRouteConstraint() });
[code]...
View 1 Replies
Feb 17, 2010
I have an application that I run in several places (demo, production, local, etc.) that all use different virtual directories for the placement of the MVC application.
I use StructureMap in this application, so I am overriding the ControllerFactory to use StructureMap to build controllers (when the passed controller instance is not null).
My problem is that the controller instance being passed to the controller factory IS null, which is fine if said route didn't exist, but it does... specifically, it should be my DEFAULT ROOT route.
Basically if I host the app at [URL], everything works fine except when I have a '/' on the end of the URL (meaning,[URL]... the latter works fine, while the former gives me the error). It looks like when that slash is there, the routing engine is deciding that it should be looking for a controller named MvcController, which doesn't exist, and which then passes the null controller instance to the ControllerFactory, resulting in the following error:
The controller for path '/Mvc/' could not be found or it does not implement IController.
My Default route is the standard default route. Removing all other routes has no effect. My default controller is HomeController.
View 3 Replies
Jan 12, 2011
I am using URL Routing to route user to his profile page, which is a child page. Now the problem is that all the images, javascripts references are distorted when i user the url to reach that page whether logged in or not logged in (both the cases). But after reaching this page when i login from this page thru my modal popup login control, all the references seem to work fine. It is to be noted that i am still in that same page which i reached after url routing. So upon logging from here the whole page works and displays fine.
How come the references are automatically adjusted when i am logging in from this page and are not referenced when i log in from other page and route here or when i am logged out?
Global.asax code:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.Add("UseridRoute", new Route
(
"profile/{user}",
new CustomRouteHandler("~/UserProfile.aspx")
));
}
View 2 Replies
Aug 20, 2010
I am able to route my urls to an existing page. Here is how our scenario is currently working:
On Default.aspx, we have several links that link to pdf files on the server. The filenames of these files change dynamically which is why we need the url routing. When the user clicks on of the urls, the link is routed to the getFile.aspx page that has logic in it to determine which file to open.
Is there a way to have the getFile.aspx page to open in the same window as the default.aspx page?
Otherwise, I need for the getFile.aspx page to close after the intended processing is complete, and I've not been able to close it without getting the close window dialog box. I figure if it opens in the same browser window, I can redirect back to the default.aspx page when processing is finished.
View 1 Replies
Jul 27, 2010
Is it possible to route all the request to the same page without displaying the name of the page in the url.
For exemple, how can I route [URL] and [URL] to index.cshtml
View 10 Replies
Jun 5, 2010
I have spent several hours today reading up on doing Custom Routing in ASP.NET MVC. I can understand how to do any type of custom route if it expands from or is similar/smaller than the Default Route. However, I am trying figure out how to do a route similar to:
/Language/{LanguageID}/Question/{QuestionID}/
And what I would like, too, is similar to how SO works. Something like:
/Language/{LanguageID}/Arabic/Question/{QuestionID}/Some-Question-Title
Where "Arabic" and "Some-Question-Title" can be almost anything because what really matters is the ID's
A complete url example might be
[URL]
Am I going beyond what can be done with the extended URL past the language ID?
View 1 Replies
Jan 18, 2011
I have a Default.aspx program that contains a Treeview with a SiteMapDataSource. I also have a web.sitemap loaded up with urls. When I run the deafult app I get the tree layout that matches the numbers of options but no text on any of the options to click.
View 1 Replies
Mar 13, 2011
I tried to mix asp.net 4 webfrom and ASp.Net MVC 3. I add required lines in webconfig, but I've issues implementing route in global.asax
Currently I use several routes for webfroms. routs template are like below
routes.MapPageRoute("Node", _
"article/sport/{nID}/", _
"~/article/articleview.aspx")
I encounter error, when I add below lines to global.asax
routes.MapRoute( _
"Defaultss", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional} _
)
I want to know how could I mix ASp.Net MVC routes with webforms routes.
View 3 Replies
Mar 9, 2010
when i run the app i got this error
A route named 'Admin_default' is already in the route collection. Route names must be unique.
Parameter name: name
this is my AdminAreaRegistration
[Code]....
View 2 Replies
Sep 24, 2010
I have a url that I want to map routing to:
[URL]
where tabvalue is one of: "personal", "professional", "values" or nothing.
I want to map it to a route like:
Member/Edit/{tab}
But my problem is - I don't know how to specify such constraints. I'm trying this regex:
^[personal|professional|values]{0,1}$
but it only works when I use url
[URL]
[URL]
and doesn't work for
[URL]
how to specify the correct constraint?
P.S. I'm not using MVC, just asp.net WebForms
View 6 Replies
Jul 20, 2010
I tried everything I could find, but still does not work on IIS routing.
View 2 Replies
Dec 12, 2010
I am using:
ASP.NET 3.5 SP1 with Web Forms Routing thru Global.asax (System.Web.Routing and RegisterRoutes)IIS 7
Everything is working fine in my local machine, but it gives the following error in my hosting environment:
Could not load file or assembly 'System.Web.Routing, Version=3.5.0.0, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I did everything inside my web.config file mentioned in the following link:
[URL]
But I am still getting the above error.
What else am I supposed to do fix the error?
View 1 Replies
Mar 14, 2011
Was looking at asp.net mvc complex routing for tree path as an example of how to define a custom route handler for my MVC app. Essentially, I want to give the end user ultimate flexibility in defining the URL for any given page, so I provide them with a field in the interface to specify their own custom URL.
My custom route handler is basically a wild-card handler. It will do a lookup and if it finds a match, map it accordingly. However, if no match is found, I want it to fall back and find the next rule that matches in the global.asax. Is that possible? Or do I essentially need to code the mappings that used to exist in my global.asax into my custom route handler?
View 2 Replies
Feb 22, 2011
I have a Web application where i have added a reference to a RESTful WCF. I got the WCF url Routing to work in my webapplication by adding Inherits="RestService.Global" to the Web applications Global.asax.
<%@ Application Codebehind="Global.asax.cs" Inherits="RestService.Global" Language="C#" %>
But then i tried to create url Routing for the Web application and it does not work with the Inherits="RestService.Global" in the Global.asax. If i take it away it works fine. Is there a correct way to do this.
View 1 Replies
Jan 31, 2011
I'm trying to create my own CMS and I've gotten a little bit stuck at the stage of URL routing.
I want clean URLs without extensions and I'd like to be able to create and modify them in a web based interface without any messing around with IIS or actual files.
I've seen how to create a static route, but for that I need to go into my Global.asax file and manually add it.I would like to have all of these routes stored in a database so that I can easily modify them later.
Does anyone know how this can be achieved?
Just for extra information, I will be attempting to create a feature so that if a path exists, but is later changed, a 301 redirect is created to the new URL, is this also possible? (My first problem is the main issue, but thought I might ask this as well just in case it makes a difference)
View 2 Replies
Sep 2, 2010
How to handle asp.net mvc routing along with asp.net webform routing. I have merged my mvc app into my existing web application. In my web application i have implement routing as below:
routes.Add("View Product Details", new Route("Product/{City}/{Manufacturer}/{Name}/{ProductID}/{*ProductType}"));
Similarly i have implemented routing in mvc as below
routes.MapRoute("Product Details",
"Product/{City}/{Manufacturer}/{Name}/{ProductID}/{ProductType}",
new
{
controller = "Home",
action = "ProductDetails",
City= UrlParameter.Optional,
Manufacturer= UrlParameter.Optional,
Name= UrlParameter.Optional,
ProductID= UrlParameter.Optional,
ProductType= UrlParameter.Optional
});
How to handle both pages, as one is custom web form while other is asp.net mvc view?
View 1 Replies
May 19, 2010
I have a stored procedure that returns 3 tables within the single recordset it returns. If I set a SqlDataSource to get data from this procedure, it works, but it only returns the first table. I want to have a GridView display the data from the 2nd or 3rd table using a SqlDataSource, but I can't figure out how to specify a particular table.
While there are some posts discussing this out there, I can't get a definitive answer about whether or not this is even possible (?). In a worst-case scenario, I can create another SP that only returns the 3rd table - but that creates a little maintenance headache that I would prefer to avoid.
View 4 Replies
May 25, 2010
For context: First of all, I am new to LINQ, as I have been using SubSonic for quite some time now.
I have two tables, Users, and Affiliates. They both have a very typical schema. The FK that joins them is the UserId field, which is in the Affiliates table. I want to create a LINQ query that pulls the Username from the Users table using the AffiliateId value. The AffiliateId is a primary key of the Affiliates table.
I have tried to accomplish this using many variations of the following code:
[Code]....
In the above query, I expect to get a single row result set. However, I instead receive the entire table of results.
How can I make this work? I have yet to see an example or article out there to do what I am trying to do.
View 9 Replies
Feb 27, 2010
I have huge excel files that I have to open from web browser. It takes several minutes to load huge file. Is it possible to open a single worksheet (single tab) at a time from excel file that contains many worksheets? I have to do this using C# / asp.net MVC
View 5 Replies
Sep 20, 2010
I am trying something apart of my boundries, is there any way to disable a single intem in dropdownlist or stop the ddl change event for a single item.
View 2 Replies
Nov 30, 2010
Response.RedirectPermanent(Url); can redirect permanently to a url.
However, during my SEO process, I decided to change my routhing rule.
For example,
I change "/tag/{tag}-quotes" routing rule to "quoes-about/{tag}", but I don't want to lose all the traffic to old routing url.
What is the best way to handle this permanent redirection?
View 4 Replies