Copy codeThe Code is as follows:
# Remove the specified parameter from the region URL
/// <Summary>
/// Remove the specified parameter
/// </Summary>
/// <Param name = "url"> address </param>
/// <Param name = "param"> parameter </param>
/// <Returns> </returns>
Public static string buildurl (string url, string param)
{
String url1 = url;
If (url. IndexOf (param)> 0)
{
If (url. IndexOf ("&", url. IndexOf (param) + param. Length)> 0)
{
Url1 = url. substring (0, url. indexOf (param)-1) + url. substring (url. indexOf ("&", url. indexOf (param) + param. length) + 1 );
}
Else
{
Url1 = url. Substring (0, url. IndexOf (param)-1 );
}
Return url1;
}
Else
{
Return url1;
}
}
# Endregion
# Region "retrieve page url"
/// <Summary>
/// Obtain the parameters of the current access page address
/// </Summary>
Public static string GetScriptNameQueryString
{
Get
{
Return HttpContext. Current. Request. ServerVariables ["QUERY_STRING"]. ToString ();
}
}
/// <Summary>
/// Obtain the address of the current access page
/// </Summary>
Public static string GetScriptName
{
Get
{
Return HttpContext. Current. Request. ServerVariables ["SCRIPT_NAME"]. ToString ();
}
}
/// <Summary>
/// Obtain the Url of the current access page
/// </Summary>
Public static string GetScriptUrl
{
Get
{
Return GetScriptNameQueryString = ""? GetScriptName: string. Format ("{0 }? {1} ", GetScriptName, GetScriptNameQueryString );
}
}
/// <Summary>
/// Obtain the parameters of the current access page
/// </Summary>
Public static string GetScriptNameQuery
{
Get
{
Return HttpContext. Current. Request. Url. Query;
}
}
# Endregion
Remove multiple parameters. Buildurl (url, param1), param2), param3)