The name request does not exist in the current context
Below was code I was using:
if (!String.IsNullOrWhiteSpace(Convert.ToString(Request.QueryString["Source"])))
{
Context.Response.Redirect(Convert.ToString(Request.QueryString["Source"]));
}
Solution:
Solution is very easy. First, you need to add below reference in your code:
using System.Web;
This will allow you to use "HttpContext.Current" in your code. So your final solution should look like below:
if (HttpContext.Current != null && !String.IsNullOrWhiteSpace(Convert.ToString(HttpContext.Current.Request.QueryString["Source"])))
{
Context.Response.Redirect(Convert.ToString(HttpContext.Current.Request.QueryString["Source"]));
}
No comments:
Post a Comment