How to enable command Response.Write in C# (as referencing class for webapp ASP.NET)

2.5k Views Asked by At

I want to make procedure like this code below:

void accessBySession(String user, String webqname)
{
  ...
  Response.Write("<script>alert('You can't access this page !');document.location='dashboard.aspx'; </script>  ");
}

I've added using System.Web; but still there is an error in command response (The name 'Response' does not exist in current context).

How to solve this?

1

There are 1 best solutions below

1
On BEST ANSWER

Try the full namespace:

System.Web.HttpContext.Current.Response.Write("<script>alert('You can't access this page !');document.location='dashboard.aspx'; </script>)