I want to make a method in my tools library that request the querystring from the url.
I created the following code, but i can’t use the HttpContext in a class library.
public string RequestString(string requestParam, string Default)
{
string param = HttpContext.Current.Request.QueryString[requestParam];
if (param != null)
{
return param;
}
else
{
return Default;
}
}
I know it is possible, but i can’t remember how…
You need to add a reference to the
System.Web.dllassembly in your class library project.But of course you will only be able to access the query string when your method is called in the context of a HTTP request.
See this MSDN page for more information about the HttpContext class.