Response.End question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TheCornjerker

    Response.End question

    Does a Response.End close down all data connection and readers? If I
    do something like this....

    cn.open()
    dr=cm.executere ader
    if dr.read() then
    ' do something good ----
    else
    response.write( 'Nothing to do')
    response.end()
    end if
    dr.close
    cm.dispose
    cn.dispose

    Other than it being bad coding practices, will it cause leaks or fail
    to close anything?
    Thanks,
    C
  • Mark Rae [MVP]

    #2
    Re: Response.End question

    "TheCornjer ker" <addoty@gmail.c omwrote in message
    news:302265de-c298-4e58-8a96-a13558b367b3@z7 2g2000hsb.googl egroups.com...
    Does a Response.End close down all data connection and readers?
    It most certainly doesn't.
    cn.open()
    dr=cm.executere ader
    if dr.read() then
    ' do something good ----
    else
    response.write( 'Nothing to do')
    response.end()
    end if
    dr.close
    cm.dispose
    cn.dispose
    >
    Other than it being bad coding practices, will it cause leaks or fail
    to close anything?
    It could - incorrectly closed / disposed ADO.NET objects is one of the most
    common reasons for poor performance of web applications - also, the above
    code doesn't include any exception handling.

    However, a much better method is to use the Using syntax which, among other
    things, allows .NET to clean up after itself (sort of):




    --
    Mark Rae
    ASP.NET MVP


    Comment

    • David

      #3
      Re: Response.End question

      Why don't you put a breakpoint on it and try it?

      On another note, if you use a try/finally and place your dr.close,
      cm.dispose, cn.dispose in the finally, they will definately run even after
      an error.

      --
      Best regards,
      Dave Colliver.

      ~~
      http://www.FOCUSPortals.com - Local franchises available


      "TheCornjer ker" <addoty@gmail.c omwrote in message
      news:302265de-c298-4e58-8a96-a13558b367b3@z7 2g2000hsb.googl egroups.com...
      Does a Response.End close down all data connection and readers? If I
      do something like this....
      >
      cn.open()
      dr=cm.executere ader
      if dr.read() then
      ' do something good ----
      else
      response.write( 'Nothing to do')
      response.end()
      end if
      dr.close
      cm.dispose
      cn.dispose
      >
      Other than it being bad coding practices, will it cause leaks or fail
      to close anything?
      Thanks,
      C

      Comment

      Working...