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

2

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.