response object

T

TJS

how do I use "response.redirect" in a class ?

I'm getting an error on "response is not declared" when I try to compile
 
P

Peter Rilling

Any class cannot call Redirect, it has to have access to an HttpResponse
instance, for instance the Response property on a Page object. You would
need to provide the Page object to any methods that need to perform a
redirect.
 
T

TJS

there must be a simple solution...

if the condition fails I want to send them to an error page

how can this be done ?
 
M

Marina

Try System.Web.HttpContext.Current.Response.Redirect.

Of course if you try to use this when there is no http context available,
the Current property will evaluate to null, and trying to get its Response
property will throw a null reference exception.
 
P

Peter Rilling

Should have thought of that. Anyway, this is the same HttpResponse instance
that the Page object has.
 
P

Peter Rilling

If that is what you want, then you should be able to configure ASP.NET to
redirect to an error page when it receives an unhandled exception.
 
M

Matt Berther

Hello TJS,

HttpContext.Current.Response.Redirect
there must be a simple solution...

if the condition fails I want to send them to an error page

how can this be done ?
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top