Questions about routing within ASP.NET (including MVC).
138
votes
4answers
21k views
Is it possible to make an ASP.NET MVC route based on a subdomain?
Is it possible to have an ASP.NET MVC route that uses subdomain information to determine its route? For example:
user1.domain.com goes to one place
user2.domain.com goes to another?
Or, can I ...
58
votes
4answers
8k views
ASP.NET MVC ambiguous action methods
I have two action methods that are conflicting. Basically, I want to be able to get to the same view using two different routes, either by an item's ID or by the item's name and its parent's (items ...
37
votes
9answers
36k views
Custom ASP.NET MVC 404 Error Page
I am trying to make a custom HTTP 404 error page when someone types in a URL
that doesn't invoke a valid action or controller in ASP.NET MVC.
Instead of it displaying the generic Resource Not Found ...
28
votes
4answers
11k views
How to get current controller and action from inside Child action?
I have a portion of my view that is rendered via RenderAction calling a child action. How can I get the Parent controller and Action from inside this Child Action.
When I use..
...
27
votes
2answers
13k views
Set “Homepage” in Asp.Net MVC
In asp.net MVC the "homepage" (ie the route that displays when hitting www.foo.com) is set to Home/Index .
Where is this value stored?
How can I change the "homepage"?
Is there anything more ...
24
votes
3answers
7k views
MVC.Net Routing
Here is my scenario. For the example lets say that I need to return a list of cars based on a search criteria. I would like to have a single View to display the results since the output will be the ...
23
votes
3answers
5k views
How can I create a friendly URL in ASP.NET MVC?
How do I generate friendly URLs within the ASP.NET MVC Framework? For example, we've got a URL that looks like this:
http://site/catalogue/BrowseByStyleLevel/1
The 1 is Id of the study level (Higher ...
21
votes
4answers
6k views
jQuery Mobile/MVC: Getting the browser URL to change with RedirectToAction
My first post...
When I use RedirectToAction the url in the browser doesn't change. How can I achieve this?
I'm switching over to ASP.NET MVC 3.0 (also using jQuery Mobile) after 10+ years using web ...
21
votes
1answer
5k views
ASP.NET MVC Areas with shared layout
I have defined an area (Admin) in my ASP.NET MVC 3 application, created _ViewStart.cshtml in that area and addedLayout = "~/Views/Shared/_Layout.cshtml"; to it to have a unified site layout.
I also ...
21
votes
2answers
4k views
How to prevent Url.RouteUrl(…) from inheriting route values from the current request
Note: I'm answering my own question immediately below
Lets say you have an action method to display products in a shopping cart
// ProductsController.cs
public ActionMethod Index(string gender) {
...
20
votes
4answers
2k views
How can I create a route constraint of type System.Guid?
Can anyone point me in the right direction on how to map a route which requires two guids?
ie. http://blah.com/somecontroller/someaction/{firstGuid}/{secondGuid}
where both firstGuid and secondGuid ...
18
votes
2answers
4k views
What's the difference in ASP.NET MVC of RedirectToRoute and RedirectToAction?
What's the difference in ASP.NET MVC of RedirectToRoute and RedirectToAction? It's not clear what the difference is to me.
16
votes
3answers
27k views
ASP.NET MVC - MapRoute versus routes.Add (and 404s)
I'm just getting started with ASP.NET MVC.
What is the difference between MapRoute and routes.Add ?
Should I just be using MapRoute? Can I map multiple routes? Which "maps" take precedence... those ...
16
votes
2answers
3k views
ASP.NET MVC: URLs with slash in parameter?
Question:
I am creating a wiki software, basically a clone of wikipedia/mediawiki, but in ASP.NET MVC (the MVC is the point, so don't recommend me ScrewTurn).
Now I have a question:
I use this ...
15
votes
2answers
4k views
Difference between “MapHttpRoute” and “MapRoute”?
Why using "MapRoute" for "Default" routing, while using "MapHttpRoute" for "DefaultApi" routing?
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: ...