在.NET执行控制器上的动作在另一区域 [英] Executing an action on a controller in another area in .net

查看:148
本文介绍了在.NET执行控制器上的动作在另一区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我需要调用另一个区域另一个控制器上的操作在.net中

So I need to call an action on another controller in another area in .net

原因是我有一些有条件的逻辑来确定是否要显示的东西,这是常见到我的网站和移动版本。

Reason being I have some conditional logic to determine whether or not to display something and that is common to my website and mobile version.

所以在我的移动网站(称为移动一个单独的区域),我想能够做到像

So in my mobile site(in a separate area called mobile) I would like to be able to do something like

@Html.Action("GetVideoHtml","Service",null)

如果服务是我的默认区域控制器和GetVideoHtml是行动,但再次,我是在移动领域。我可以复制并粘贴行动统一到一个地方行动,但似乎很傻

Where Service is a controller in my default area and GetVideoHtml is the action, however again, I am in the mobile area. I could copy and paste the action into a local action but that seems silly

在此先感谢

推荐答案

指定面积=中的路由值的伎俩:

Specifying area = "" in the route values does the trick:

@Html.Action("GetVideoHtml", "Service", new { area = "" })

这篇关于在.NET执行控制器上的动作在另一区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆