is it possible to redirect to an aspx page in an (asp.net-mvc3 )controller action? What should be the return type of the action (ActionResult?) and which redirect method should be called (RedirectToAction?).
BR,
Use this: return RedirectToAction("LogIn", "Account", new { area = "" }); This will redirect to the LogIn action in the Account controller in the "global" area.
You can use any of the following methods to return a RedirectResult: Redirect – Http Status Code 302 Found (temporarily moved to the URL provided in the location header) RedirectPermanent – Http Status Code 301 Moved Permanently. RedirectPermanentPreserveMethod – Http Status Code 308 Permanent Redirect.
To redirect the user to another action method from the controller action method, we can use RedirectToAction method. Above action method will simply redirect the user to Create action method.
If you add a plain ASPX page to an ASP.NET MVC project, well, it just works like a charm without any changes to the configuration. If you invoke the ASPX page, the ASPX page is processed with viewstate and postbacks.
You can redirect to anywhere from MVC action and you have to use RedirectResult
for that. RedirectResult
is a type of ActionResult
.
For ex.
public RedirectResult RedirectToAspx()
{
return Redirect("/pages/index.aspx");
}
Yes, just like razor.
View:
test.aspx
Controller:
public ActionResult test()
{
ViewBag.Message = "test。";
return View();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With