Friday, 18 June 2010

Method to read Request Query String / Form Parameters

public string RequestParam(string ParamName)
{
string Result = String.Empty;

if (Context.Request.Form.Count != 0)
{
Result = Convert.ToString(Context.Request.Form[ParamName]);
}
else if (Context.Request.QueryString.Count != 0)
{
Result = Convert.ToString(Context.Request.QueryString[ParamName]);
}

return (Result==null) ? String.Empty : Result.Trim();
}

2 comments: