http://blog.falafel.com/duplicate-controller-names-aspnet-mvc-areas/MVC4区域,主控制器和路由
按照此建议,我现在正在运行。但是,当击中/ area/home/index时,正确的控制器操作会触发,但它使用的是根网站的Index.cshtml,而不是Area文件夹中的Index.cshtml!任何想法如何解决这一问题?
或者还有更好的方式来处理路由来完成相同的事情吗?
目标: http://example.net/ - >的HomeController /索引(根)
http://example.net/area1 - > area1.HomeController.Index/AREA1的Index.cshtml
http://example.net/area1/NotIndex - > area1.HomeController.NotIndex/AREA1的NotIndex.cshtml
http://example.net/area2 - > area2.HomeController.Index/area2's Index.cshtml
etc ...
我尝试过不同区域的属性路由。
[RouteArea("ProductReuse")]
[Route("ProductReuse")]
public partial class ProductReuseController : BaseProductReuseController
{
[HttpGet]
[Route("Index")]
public ActionResult Index()
{
if (SessionUserLogin == null) return LoginActionResult(SessionAppName);
var serviceResponse = _productReuseService.IndexQuery(SessionUserId);
var response = _mapper.Map<IndexViewModel>(serviceResponse);
return View(response);
}
...
}
这是接近,但你还是得有一个看起来像一个URL: http://example.net/ProductReuse/Index
如果您尝试打http://example.net/ProductReuse它弹了。
TIA