如何引用其他区域?
我的主站点中有一个名为“Account”的控制器,我想在 Asp.net MVC 2 区域中引用它的方法。
默认情况下,区域似乎只能访问该区域内的控制器,这是有道理的,但似乎没有选择引用另一个区域的控制器。
谢谢!
I have a controller called "Account" in my main site and I would like to reference a method on it from with in an Asp.net MVC 2 Area.
It seems by default that Areas only have access to the controllers within that Area which makes sense, but there doesn't seem to be an option to reference controllers from another area.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个演练: http://msdn.microsoft.com/en-us/ Library/ee671793.aspx
您在routeValues 参数对象中传递区域名称。
您需要用于 Html.ActionLink 的构造函数还有一个 htmlAttributes 参数,您可以将其设置为 null。
使用空字符串作为默认区域。
Here's a walkthrough: http://msdn.microsoft.com/en-us/library/ee671793.aspx
You pass the area name in the routeValues parameter object.
The constructor you need to use for Html.ActionLink also has a htmlAttributes parameter, which you can set to null.
Use an empty string for the default area.
查看此网站,看看是否它可以帮助你。基本上,在操作链接中,您需要声明要引用的区域,就像 ID 或控制器一样。
默认区域的控制器
其他区域的控制器
Take a look at this site and see if it helps you out. Basically, in your action links, you need to declare the area you want to reference just like you would an ID or controller.
Controller in default area
Controller in another area