i can open a page (view) in browser using the address http://localhost:1234/Home/Details/id
What settings i need in global.cs so i can open the same page using
http://localhost:1234/Details/id
-
1You are not opening a page or a view - you are requesting an action. Here's a good tutorial that explains what you need: asp.net/mvc/tutorials/asp-net-mvc-routing-overview-csbzlm– bzlm2010-08-09 11:35:46 +00:00Commented Aug 9, 2010 at 11:35
-
possible duplicate of ASP.NET MVC - Removing controller name from URLJames– James2010-08-09 11:50:47 +00:00Commented Aug 9, 2010 at 11:50
Add a comment
|
1 Answer
You have to create a new URL Route:
http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx
Didn't tried it, but something like this:
routes.MapRoute(
"My Route", // Route name
"{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
It has to be bevore the default route
1 Comment
Yngve B-Nilsen
be careful with this. Putting this before the default route will potentially break alot of other urls. For instance /Account/LogOn will now look for an action on the Home-controller called "Account" and pass the Id "LogOn". Atleast the id routevalue should have a digit regex constraint.