Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error while redirecting 'Response is not available in this context'

I am using following code to redirect user to a page.

Session["USERDATA"] = user;
if (roleName.Equals("Zerker", StringComparison.CurrentCulture))
   Response.Redirect("~/Account/Dashboard.aspx");

but this causing the error.

Response is not available in this context.

What should I do?

like image 359
Diboliya Avatar asked Jan 25 '13 06:01

Diboliya


1 Answers

I think you are using response object in your own class. This object will not be available there.

Try using

HttpContext.Current.Response.Redirect("~/Account/Dashboard.aspx");
like image 64
Microsoft DN Avatar answered Oct 15 '22 00:10

Microsoft DN