Passing Information Between Controllers in ASP.Net-MVC

后端 未结 4 922
北恋
北恋 2020-12-09 22:56

This is a duplicate of How to RedirectToAction in ASP.NET MVC without losing request data


Hi, I have come into a problem which is making me scratch my head a l

4条回答
  •  执念已碎
    2020-12-09 23:21

    Because of the nature of redirects, you can only perform a GET operation.

    This means that you have to pass the parameter as part of the query string.

    So you would redirect to a url like http://host/dir/page?sendStoredInfo=true

    Then, you can chose to have it part of your method signature in the other controller, or, you can choose to access it directly using the HttpRequest exposed by the HttpContext for the operation.

    You can also call the RedirectToAction, as per this previous question:

    How to RedirectToAction in ASP.NET MVC without losing request data

提交回复
热议问题