问题描述
这code是母版页里面:
所有环节的工作很好,直到我将在区链接。当我去那里的主要区域的所有路由都不起作用。
要解决这个问题,我可以用这样的:
我的问题是,有没有办法避免,新{面积=}
在每次在主站点链接?
它很讨厌网站上的每一个环节上都没有了。
URL操作是相对于链接的位置。因此,新{面积=}
不告诉Url.Action电话,有没有面积,它告诉它使用根区 。如果省略新{面积=}
从Url.Action调用它会尝试创建一个网址为当前在指定控制器内的指定动作面积(以下简称区都是你的情况)。
因此,如果想从一个分区链接到根区域是无法避免的。
This code is inside the master page:
All the links works good till I'm going to the Area Link. When I go there all the routes of the main area don't work.
To fix that I can use this:
My question is, is there a way to avoid , new {area = ""}
on every link in the to the main site?
Its very annoying to have this on every link on the site.
Url actions are relative to the location of the link. So new {area = ""}
is not telling the Url.Action call that there is no area, it's telling it to use the root area. If you omit new {area = ""}
from the Url.Action call it will try to create a url for the specified action within the specified controller within the current area (the "Area" are in your case).
Therefore it is unavoidable if you want to link from a subarea to the root area.
这篇关于设置默认区 - 避免',新{面积=""}`在网站上的每一个环节上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!