在AspNet.Core中,标记助手asp区域不起作用

编程入门 行业动态 更新时间:2024-10-10 08:22:12
本文介绍了在AspNet.Core中,标记助手asp区域不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我最近将 Visual Studio 更新为 Update 3 ,并将 ASP.Net Core 更新为1.0.0.

I recently updated the Visual Studio for Update 3 and ASP.Net Core for 1.0.0.

我遵循了文档中的教程,我尝试设置使用区域,例如 docs.asp/en/1.0.0/mvc/controllers/areas.html

但是,生成的链接是 localhost:2187/?area = Admin ,而不是 localhost:2187/Admin/Home/Index

However, the link generated was localhost:2187/?area=Admin, instead of localhost:2187/Admin/Home/Index

更新

我的路线:

app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "areaRoute", template: "{area}/{controller=Home}/{action=Index}"); });

怎么了?

解决方案

问题出在所回答路线的顺序上.

The problem was in the order of the routes as answer mentioned.

推荐答案

这表示您没有在区域中注册的路线.

This indicates that you do not have a route registered where it takes in an area.

区域路线示例:

app.UseMvc(routes => { routes.MapRoute(name: "areaRoute", template: "{area}/{controller=Home}/{action=Index}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}"); });

更新:

您必须重新排列路线,因为在这种情况下,第一个路线将被匹配.我建议您看一下路由文档,以了解为什么顺序很重要.

You must reorder the routes as in this case the first route would be matched. I would suggest to take a look at the routing docs to know why the order is important.

更多推荐

在AspNet.Core中,标记助手asp区域不起作用

本文发布于:2023-11-03 05:16:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554323.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标记   不起作用   助手   区域   AspNet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!