在MVC使用ChildActionOnly [英] Using ChildActionOnly in MVC
问题描述
当你使用属性 ChildActionOnly
?什么是 ChildAction
在什么情况下,你会想用此属性限制的动作?
When would you use the attribute ChildActionOnly
? What is a ChildAction
and in what circumstance would you want restrict an action using this attribute?
推荐答案
的<一个href=\"https://msdn.microsoft.com/en-us/library/system.web.mvc.childactiononlyattribute(v=vs.118).aspx\"><$c$c>ChildActionOnly$c$c>属性确保操作方法只能作为一个孩子的方法被调用
从视图中。操作方法并不需要有该属性被用作一个子动作,但
我们倾向于使用这个属性prevent被援引为用户所造成的动作方法
请求。
在定义的操作方法,我们需要创造什么将被渲染时动作
调用。子的动作通常与局部视图相关联的,尽管这不是强制性的。
The ChildActionOnly
attribute ensures that an action method can be called only as a child method
from within a view. An action method doesn’t need to have this attribute to be used as a child action, but
we tend to use this attribute to prevent the action methods from being invoked as a result of a user
request.
Having defined an action method, we need to create what will be rendered when the action is
invoked. Child actions are typically associated with partial views, although this is not compulsory.
-
[ChildActionOnly]允许通过code在查看限制访问
[ChildActionOnly] allowing restricted access via code in View
国家信息实施特定页面的URL。
例如:付款页面的网址(仅支付一次)
剃刀语法允许调用特定的操作条件
State Information implementation for specific page URL. Example: Payment Page URL (paying only once) razor syntax allows to call specific actions conditional
这篇关于在MVC使用ChildActionOnly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!