1

如何访问另一个控制器中的一个控制器数据。

我正在使用 ASP.NET MVC 4。我正在尝试访问另一个控制器中的一个控制器属性。我不明白这个。我不确定这是否可能?

这是我的表单控制器属性:

public string CorticonServiceEndpoint { get; set; }

    public string CorticonServiceName { get; set; }

    public string CorticonServiceMajorVersion { get; set; }

    public string CorticonServiceMinorVersion { get; set; }

而且我的表单控制器没有操作,而是有 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 属性?

为了更好地理解,我在下面的 URL 分享了一个视频

https://drive.google.com/open?id=0B1Z7d8OTSWR4NDFadXVueUt2MFE

4

0 回答 0