[英]asp.net mvc routing, with area as parameter
I'm building a website for multiple organizations. 我正在为多个组织建立一个网站。 For example, people could go to mydomain.com/org1/home/index or mydomain.com/org2/home/index.
例如,人们可以访问mydomain.com/org1/home/index或mydomain.com/org2/home/index。
What I am trying to do is have the following routing, 我正在尝试做的是以下路由,
mydomain.com/{area}/{controller}/{action}/{id} mydomain.com/{area}/{controller}/{action}/{id}
I can't figure out how to do this, and frankly not even sure how to even start setting up my routing. 我不知道该怎么做,坦白说,我什至不知道如何开始设置路由。 I want to be able to access {area} string in order to decide which images to display, what text etc.
我希望能够访问{area}字符串以便确定要显示的图像,什么文本等。
I hope I'm making sense with what I'm trying to do. 我希望我对自己想做的事情有所了解。
routes.MapRoute(
name: "Default",
url: "{area}/{controller}/{action}/{id}"
defaults: new {
controller = "Home",
action = "Index",
id = UrlParameter.Optional,
area = UrlParameter.Optional
);
Your Home controller will look something like this: 您的Home控制器将如下所示:
public ActionResult Index(string area, string id)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.