別のコントローラー内の 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; }
そして、フォームコントローラーには Action がなく、代わりに ajax submit があります。
[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
});
}
ここにもう 1 つのコントローラー (ResponseController) があり、このコントローラーからフォーム コントローラーのプロパティを読み取ります。
[HttpPost]
public ActionResult Index(FormCollection formCollection)
{
var viewModel = this.Model.GetViewModel(payLoad);
return View(CorticonResponseModel.viewName, viewModel);
}
フォームの送信時に、HttpPost 属性を持つ ActionResult がトリガーされ、さらに処理するためにフォーム コントローラーのプロパティが必要になります。
TempData、セッションなどを使用することは知っています.2つのコントローラーで、あるアクションから別のアクションにコントローラーデータを渡すことができます。Response コントローラーで FormController プロパティにアクセスすることは可能ですか?
理解を深めるために、以下の URL でビデオを共有しました。
https://drive.google.com/open?id=0B1Z7d8OTSWR4NDFadXVueUt2MFE