In ASP.NET MVC, how does response.redirect work?

后端 未结 5 1280
长情又很酷
长情又很酷 2020-12-13 13:49

I have used response.redirect in classic ASP and ASP.NET webforms. However, with MVC 2.0, I am running into something peculiar.

I have a private method in a contr

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 14:38

    its recommended and its the only way to redirect to asp.net form in mvc controller action by using

    return Redirect("/page/pagename.aspx");
    

    other way we can redirect by using ( not recommended and bad way )

    Response.Redirect("/page/pagename.aspx", true);
    

    it will work for redirect, but problem is it will clear all of our Session values. so why its not recommended.

提交回复
热议问题