The following is my routes definition from global.asax.cs:
以下是我在global.asax.cs中的路由定义:
routes.Add(
new NamedTypedRoute(
"feedback-en", RouteType.Regular, "{culture}/Feedback",
new RouteValueDictionary(
new
{
culture = "en",
controller = "Feedback",
action = "Index"
}
),
null,
new MultiLingualMvcRouteHandler()
)
);
routes.Add(
new NamedTypedRoute(
"feedback-sl", RouteType.Regular, "{culture}/Kontakt",
new RouteValueDictionary(
new
{
culture = "sl",
controller = "Feedback",
action = "Index"
}
),
null,
new MultiLingualMvcRouteHandler()
)
);
If I do this in the view
如果我在视图中这样做
<%: Html.ActionLink("sl", "feedback-sl")%> | <%: Html.ActionLink("en", "feedback-en")%>
the constructed URL points to the root site (no controller/action information is included in the constructed link).
构造的URL指向根站点(构造的链接中不包含控制器/操作信息)。
If I do this in the view
如果我在视图中这样做
<%: Html.RouteLink("sl", "feedback-sl")%> | <%: Html.RouteLink("en", "feedback-en")%>
an exception occurs:
发生异常:
"A route named 'feedback-sl' could not be found in the route collection.
Parameter name: name"
My two questions:
我的两个问题:
1
Html.ActionLink extension renders an anchor element that links to an action. Html.RouteLink extension on the other hand renders an anchor element which could resolve to an action method, a file, a folder, or some other resource. The RouteLink doesn't really take ActionName and ControllerName strings like the ActionLink. From more detail look a bit at the parameter names for the parameters. The descriptions here are not really well written in MSDN/IntelliSense.
Html.ActionLink扩展程序呈现链接到操作的锚元素。另一方面,Html.RouteLink扩展呈现了一个可以解析为操作方法,文件,文件夹或其他资源的锚元素。 RouteLink实际上并不像ActionLink那样采用ActionName和ControllerName字符串。从更多细节看一下参数的参数名称。这里的描述在MSDN / IntelliSense中写得不是很好。
Sadly I don't have an answer for the second question.
可悲的是,我对第二个问题没有答案。
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2010/11/15/e71f179fe1e9f2a3959dd8b625c3c021.html。