区域内的行动
我在区域内有一个母版页,在区域外有一个控制器。控制器称为“SecurityController”,我正在调用 <%= Url.Action("LogOut", "Security", new {area=""}) %>;正如我在一些帖子中看到的那样,但这并不映射到我的“根”控制器。 该链接是为 /AREANAME/SecurityController/ 生成的,这是错误的。
我做错了什么?
谢谢大家。
I have a masterpage inside a Area and a Controller outside the area. The controller's called "SecurityController" and i'm calling <%= Url.Action("LogOut", "Security", new {area=""}) %> as i saw in some posts but that doens't map to my "root" controllers.
The link is generated for /AREANAME/SecurityController/ witch's wrong.
What i'm doing wrong?
Thank U all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法重现您所描述的行为。以下是我执行的步骤:
AREANAME
的新区域在
~/ 内添加一个 FooController Areas/AREANAME/Controller/FooController.cs
:~/Views/Shared/Site.Master 复制粘贴母版页
到~/Areas/AREANAME/Views/Shared/Site.Master
Index
视图,对应于Index
操作使用母版页的FooController
。将其保留为默认值。在该区域的母版页内的某个位置添加以下内容(或在 FooController 的索引视图内,这并不重要):
/AREANAME/foo /索引
。/
如果删除助手的
area=""
部分,则会生成以下 url:/AREANAME/Home
。所以?
I was unable to reproduce the behavior you are describing. Here are the steps I did:
AREANAME
using the Visual Studio WizardAdd a FooController inside
~/Areas/AREANAME/Controller/FooController.cs
:~/Views/Shared/Site.Master
to~/Areas/AREANAME/Views/Shared/Site.Master
Index
view corresponding to theIndex
action of theFooController
using the master page. Leave it as default.Somewhere inside the master page of the area add the following (or inside the Index view of the FooController, it doesn't really matter):
/AREANAME/foo/index
./
If you remove the
area=""
part of the helper the following url is generated:/AREANAME/Home
.So?