如何访问另一个控制器中的一个控制器数据。
我正在使用ASP.NET MVC 4.我正在尝试访问另一个控制器中的一个控制器属性。我没有得到这个。我不确定这是否可能?
以下是我的formcontroller属性:
public string CorticonServiceEndpoint { get; set; }
public string CorticonServiceName { get; set; }
public string CorticonServiceMajorVersion { get; set; }
public string CorticonServiceMinorVersion { get; set; }
我的表单控制器没有Action,而是提交了ajax。
[StandaloneResponseFilter]
[HttpPost]
public JsonResult AjaxSubmit(FormCollection collection)
{
SubmitStatus submitedSuccessfully = this.Model.TrySubmitForm(collection, this.Request.Files, this.Request.UserHostAddress);
if (submitedSuccessfully != SubmitStatus.Success && this.Model.RaiseBeforeFormActionEvent())
return this.Json((object)new
{
success = false,
error = this.Model.GetSubmitMessage(submitedSuccessfully)
});
return this.Json((object)new
{
success = true,
error = string.Empty
});
}
这是另外一个控制器(ResponseController),我想从这个控制器读取表单控制器属性。
[HttpPost]
public ActionResult Index(FormCollection formCollection)
{
var viewModel = this.Model.GetViewModel(payLoad);
return View(CorticonResponseModel.viewName, viewModel);
}
在表单提交时,将触发带有HttpPost属性的ActionResult,然后我需要表单控制器属性进行进一步处理。
我知道使用TempData,会话等。我们可以将控制器数据从一个动作传递到两个控制器中的另一个动作。是否可以在响应控制器中访问FormController属性?
为了更好地理解,我在以下网址分享了一个视频
https://drive.google.com/open?id=0B1Z7d8OTSWR4NDFadXVueUt2MFE