Response.Redirect not ending execution

前端 未结 6 1331
再見小時候
再見小時候 2020-12-10 03:01

I have Default.aspx page, which inherits from BasePage.cs, which inherits from System.Web.UI.Page. BasePage is where I do some common things every page must do upon loading

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 03:41

    You can throw an exception, that will exit code execution, but still redirect:

    HttpContext.Current.Response.Redirect("/login", true);
    throw new Exception("Unauthorized Access");
    

提交回复
热议问题