Diboliya
Diboliya

Reputation: 1174

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?

Upvotes: 15

Views: 34861

Answers (1)

Microsoft DN
Microsoft DN

Reputation: 10030

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");

Upvotes: 39

Related Questions