Link to home
Start Free TrialLog in
Avatar of Karla77
Karla77

asked on

Response.Redirect

I have a application project that has all .cs files. My main project References to the application. In one of my .cs file I have a method that I want to redirect to another page every time it's called. I did Response.Redirect(""); but it says The type or namespace name 'Response' could not be found (are you missing a using directive or an assembly reference?)
Any clue on where to go from here?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

If you are calling this from a class file, then you need:

System.Web.HttpContext.Current.Response

Bob
hi,
response.redirect will work only if the page is inherited from  System.Web.UI.Page
i think u have written Response.reditect in a class file

b u d d h a
Avatar of Karla77
Karla77

ASKER

If you can't use Response.redirect in a .cs file is there something like Response.redirect that you can use.
You can use Response.Redirect in a .cs file, you just need to use what I showed above.

System.Web.HttpContext.Current.Response.Redirect

Bob
Avatar of Karla77

ASKER

I tried that and I still got The type or namespace name 'HttpContext' does not exist in the class or namespace 'System.Web' (are you missing an assembly reference?)

System.Web.HttpContext.Current.Response.Redirect("");

Is there something else I might have missed?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Karla77

ASKER

yes I do.