Thursday, 8 May 2014

How to get parameter from url string in c#

use inbuilt HttpUtility Method ParseQueryString.
private NameValueCollection GetQueryParameters(string dataWithQuery)
{
   return  HttpUtility.ParseQueryString(dataWithQuery);
}

string LinkUrl = "http://www.sujoysantra.com?month=jan&day=sun";
NameValueCollection dtQueryString = GetQueryParameters(LinkUrl);
string month = dtQueryString["month"]; //jan