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

  • Thread starter Thread starter Pepehammer
  • Start date Start date
P

Pepehammer

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 you give us some more details about how this method is called?
Seeing the call stack might provide some good information.
 
Not trying to use this in global.asax file are you?

Greg
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.
 
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.

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
 

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top