简体   繁体   English

获取负责该帖子的PartialView操作和控制器

[英]Get PartialView action and controller responsible for the post

I have a PartialView, on a form that does an ajax post. 我在执行ajax发布的表单上有一个PartialView。 All my controller's inherit from a base controller that has a property on it "ReferringPartialView". 我所有控制器的继承自具有“ ReferringPartialView”属性的基本控制器。

I need to somehow set that property and allow a user to make use of it in the post action. 我需要以某种方式设置该属性,并允许用户在后期操作中使用它。

I figure i need to override "OnActionExecuting", so i have done so, but no where can i find out which "PartialView" actually made the post. 我认为我需要重写“ OnActionExecuting”,所以我这样做了,但是我无法在哪里找出哪个“ PartialView”实际发了帖。

I had a look at the ActionExecutingContext, but that either gives me the referring URL, or the current action, but not the referring PartialView. 我看了一下ActionExecutingContext,但是它要么为我提供了引用URL,要么为我提供了当前操作,但没有给我提供PartialView。

I hope this makes sense :) 我希望这是有道理的 :)

There is no info in the request that allows you to determine which partial view made the request. 请求中没有任何信息,您可以通过它确定哪个局部视图发出了请求。

You'll need to establish some convention to achieve what you want. 您需要建立一些约定以实现所需的功能。 A hidden field, a variation of the url, a query string value, in other words something custom you add to the form post. 一个隐藏字段,URL的变体,查询字符串值,换句话说,您将自定义添加到表单发布中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM