Why i get this error: Response is not available in this context

Discussion in 'ASP .Net' started by Pepehammer, Jul 21, 2004.

  1. Pepehammer

    Pepehammer Guest

    Exception Details: System.Web.HttpException: Response is not available in
    this context.

    Source Error:

    Line 16: '---------- // SUB : WriteString
    Line 17: Public Sub WriteString(SayItNow as String)
    Line 18: Response.Write(SayItNow)
    Line 19: End Sub
    Line 20:
     
    Pepehammer, Jul 21, 2004
    #1
    1. Advertising

  2. Pepehammer

    Scott Allen Guest

    Can you give us some more details about how this method is called?
    Seeing the call stack might provide some good information.

    --
    Scott
    http://www.OdeToCode.com

    On Wed, 21 Jul 2004 18:52:12 -0400, "Pepehammer"
    <> wrote:

    >Exception Details: System.Web.HttpException: Response is not available in
    >this context.
    >
    >Source Error:
    >
    >Line 16: '---------- // SUB : WriteString
    >Line 17: Public Sub WriteString(SayItNow as String)
    >Line 18: Response.Write(SayItNow)
    >Line 19: End Sub
    >Line 20:
    >
     
    Scott Allen, Jul 22, 2004
    #2
    1. Advertising

  3. Pepehammer

    Greg Burns Guest

    Not trying to use this in global.asax file are you?

    Greg

    "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
    news:...
    > Can you give us some more details about how this method is called?
    > Seeing the call stack might provide some good information.
    >
    > --
    > Scott
    > http://www.OdeToCode.com
    >
    > On Wed, 21 Jul 2004 18:52:12 -0400, "Pepehammer"
    > <> wrote:
    >
    > >Exception Details: System.Web.HttpException: Response is not available in
    > >this context.
    > >
    > >Source Error:
    > >
    > >Line 16: '---------- // SUB : WriteString
    > >Line 17: Public Sub WriteString(SayItNow as String)
    > >Line 18: Response.Write(SayItNow)
    > >Line 19: End Sub
    > >Line 20:
    > >

    >
     
    Greg Burns, Jul 22, 2004
    #3
  4. On 7/21/2004 10:00 PM, Greg Burns wrote:
    > Not trying to use this in global.asax file are you?
    >
    > Greg
    >
    > "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
    > news:...
    >
    >>Can you give us some more details about how this method is called?
    >>Seeing the call stack might provide some good information.
    >>
    >>--
    >>Scott
    >>http://www.OdeToCode.com
    >>
    >>On Wed, 21 Jul 2004 18:52:12 -0400, "Pepehammer"
    >><> wrote:
    >>
    >>
    >>>Exception Details: System.Web.HttpException: Response is not available in
    >>>this context.
    >>>
    >>>Source Error:
    >>>
    >>>Line 16: '---------- // SUB : WriteString
    >>>Line 17: Public Sub WriteString(SayItNow as String)
    >>>Line 18: Response.Write(SayItNow)
    >>>Line 19: End Sub
    >>>Line 20:
    >>>

    >>

    >
    >

    Can almost guarantee it's being used outside of Page, etc. You have to
    use System.Web.HttpContext.Current.Request to access request in
    'non-web' classes.

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
     
    Craig Deelsnyder, Jul 22, 2004
    #4
  5. Pepehammer

    Greg Burns Guest

    > Can almost guarantee it's being used outside of Page, etc. You have to
    > use System.Web.HttpContext.Current.Request to access request in
    > 'non-web' classes.


    Yes, very true. You can use that inside any class not inhereting from Page.

    > >>>Exception Details: System.Web.HttpException: Response is not available

    in
    > >>>this context.


    But, this specific error I've seen when trying to Response.Redirect from
    events like Session_End until you learn you just can't to do that. :)

    Greg
     
    Greg Burns, Jul 22, 2004
    #5
  6. Pepehammer

    CTifer Guest


    > B>


    Thanks, Craig. I was having this issue and your answered helped me i
    my scenario. I even registered for these forums just to give thi
    thread my seal of approval


    -
    CTife
    -----------------------------------------------------------------------
    Posted via http://www.codecomments.co
    -----------------------------------------------------------------------
     
    CTifer, May 4, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MS News \(MS LVP\)

    Re: Response is not available in this context

    MS News \(MS LVP\), Aug 7, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,098
    MS News \(MS LVP\)
    Aug 7, 2003
  2. rao
    Replies:
    1
    Views:
    3,313
  3. Replies:
    0
    Views:
    10,234
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,226
    Smokey Grindel
    Dec 2, 2006
  5. Flip Rayner
    Replies:
    1
    Views:
    734
    bruce barker
    Jan 23, 2007
Loading...

Share This Page