By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

response object

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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.

"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
how do I use "response.redirect" in a class ?

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

Nov 18 '05 #2

P: n/a
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 ?
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
how do I use "response.redirect" in a class ?

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


Nov 18 '05 #3

P: n/a
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.

"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
how do I use "response.redirect" in a class ?

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

Nov 18 '05 #4

P: n/a
Should have thought of that. Anyway, this is the same HttpResponse instance
that the Page object has.
"Marina" <so*****@nospam.com> wrote in message
news:OJ**************@TK2MSFTNGP12.phx.gbl...
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.

"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
how do I use "response.redirect" in a class ?

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


Nov 18 '05 #5

P: n/a
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.

"TJS" <no****@here.com> wrote in message
news:OM*************@TK2MSFTNGP11.phx.gbl...
there must be a simple solution...

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

how can this be done ?
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
how do I use "response.redirect" in a class ?

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



Nov 18 '05 #6

P: n/a
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 ?

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
how do I use "response.redirect" in a class ?

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

--

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #7

P: n/a
TJS
thanks all ... your suggestions worked
"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
how do I use "response.redirect" in a class ?

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

Nov 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.