Is Response.End() considered harmful?

前端 未结 9 875
陌清茗
陌清茗 2020-11-22 01:01

This KB Article says that ASP.NET\'s Response.End() aborts a thread.

Reflector shows that it looks like this:

public void End()
{
            


        
9条回答
  •  粉色の甜心
    2020-11-22 01:36

    I've used Response.End() in both .NET and Classic ASP for forcefully ending things before. For instance, I use it when there is a certian amount of login attempts. Or when a secure page is being accesed from an unauthenticated login (rough example):

        if (userName == "")
        {
            Response.Redirect("......");
            Response.End();
        }
        else
        {
          .....
    

    When serving files to a user I'd use a Flush, the End can cause issues.

提交回复
热议问题