开发者

Asp.net MVC route url

开发者 https://www.devze.com 2023-01-11 05:48 出处:网络
i can open开发者_如何学C a page (view) in browser using the address http://localhost:1234/Home/Details/id

i can open开发者_如何学C 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消