如何在ASP.net MVC中设置自定义URL? [英] How to set a Custom url in ASP.net MVC?
本文介绍了如何在ASP.net MVC中设置自定义URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ASP.net MVC中有一个Web应用程序,我必须设置一个自定义URL而不是默认URL.网址类似:www.hostname.com//IEAdmin/OUser/ViewStep1/a0a765a1-21a5-47d2-8ac5-bcef10baf76c
I have one web application in ASP.net MVC and I have to set a custom url instead of default url. Url like : www.hostname.com//IEAdmin/OUser/ViewStep1/a0a765a1-21a5-47d2-8ac5-bcef10baf76c
我需要类似www.hostname.com/OUser/a0a765a1-21a5-47d2-8ac5-bcef10baf76c这样的网址
I need url like www.hostname.com/OUser/a0a765a1-21a5-47d2-8ac5-bcef10baf76c
是possilbe吗?
Is it possilbe ?
让我知道是否有可能
我必须在Route.config中设置哪些配置.
Which configuration i have to set in Route.config.
推荐答案
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("MyRoute", "OUser/{id}", new { controller = "MyController", action = "MyAction" }, new { id = UrlParameter.Optional });
}
这篇关于如何在ASP.net MVC中设置自定义URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文