Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ASP.NET MVC中配置具有3个级别的URL?_Asp.net_Asp.net Mvc_Routing_Url Routing - Fatal编程技术网

如何在ASP.NET MVC中配置具有3个级别的URL?

如何在ASP.NET MVC中配置具有3个级别的URL?,asp.net,asp.net-mvc,routing,url-routing,Asp.net,Asp.net Mvc,Routing,Url Routing,使用ASP.NET MVC,我需要如下配置我的URL: www.foo.com/company:render View company www.foo.com/company/about:render View company www.foo.com/company/about/mission:render View mission 如果“公司”是我的控制者,“关于”是我的行动,“使命”应该是什么 对于每个“文件夹”(公司、关于和任务),我必须呈现不同的视图 谁知道我该怎么做 谢谢 首先,设置视

使用ASP.NET MVC,我需要如下配置我的URL:

www.foo.com/company:render View company

www.foo.com/company/about:render View company

www.foo.com/company/about/mission:render View mission

如果“公司”是我的控制者,“关于”是我的行动,“使命”应该是什么

对于每个“文件夹”(公司、关于和任务),我必须呈现不同的视图

谁知道我该怎么做


谢谢

首先,设置视图:

Views\
  Company\
    Index.aspx
    About.aspx
    Mission.aspx
    AnotherAction.aspx
在GlobalAsax.registerOutes(RouteCollection routes)方法中:

在控制器中:

CompanyController
{
  public ViewResult Index() { return View(); }
  public ViewResult About() { return View(); }
  public ViewResult Mission() { return View(); }
  public ViewResult AnotherAction() { return View(); }
}
CompanyController
{
  public ViewResult Index() { return View(); }
  public ViewResult About() { return View(); }
  public ViewResult Mission() { return View(); }
  public ViewResult AnotherAction() { return View(); }
}