1

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

coure2011
  • 40,286
  • 83
  • 216
  • 349
  • 1
    You are not opening a page or a view - you are requesting an action. Here's a good tutorial that explains what you need: http://www.asp.net/mvc/tutorials/asp-net-mvc-routing-overview-cs – bzlm Aug 09 '10 at 11:35
  • possible duplicate of [ASP.NET MVC - Removing controller name from URL](http://stackoverflow.com/questions/3337372/asp-net-mvc-removing-controller-name-from-url) – James Aug 09 '10 at 11:50

1 Answers1

3

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

Arthur
  • 7,939
  • 3
  • 29
  • 46
  • 2
    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. – Yngve B-Nilsen Aug 09 '10 at 12:32