例如地址栏:
http://localhost:19304/BalloonShopTest/Catalog.aspx?DepartmentID=1&CategoryID=1string departmentId = Request.QueryString["DepartmentID"];
string categoryId = Request.QueryString["CategoryID"];为什么categoryId是空的,取不到值1
http://localhost:19304/BalloonShopTest/Catalog.aspx?DepartmentID=1&CategoryID=1string departmentId = Request.QueryString["DepartmentID"];
string categoryId = Request.QueryString["CategoryID"];为什么categoryId是空的,取不到值1
http://localhost:19304/BalloonShopTest/Catalog.aspx?DepartmentID=1&CategoryID=1
string departmentId = Request.QueryString["DepartmentID"];
string categoryId = Request.QueryString["CategoryID"];
1楼正解
private static string BuildAbsolute(string relativeUri)
{
Uri uri = HttpContext.Current.Request.Url;
string app = HttpContext.Current.Request.ApplicationPath;
if (!app.EndsWith("/"))
{
app += "/";
}
relativeUri = relativeUri.TrimStart('/');
return HttpUtility.HtmlEncode
(string.Format("http://{0}:{1}{2}{3}", uri.Host, uri.Port, app, relativeUri));
}
return BuildAbsolute(String.Format("Catalog.aspx?DepartmentID={0}&CategoryID={1}", departmentID, categoryID));
连接符amp;是net自动在地址栏加的,下面状态栏显示是没的
红色部分换掉
http://localhost:19304/BalloonShopTest/Catalog.aspx?DepartmentID=1&CategoryID=1
HtmlEncode: 将 Html 源文件中不允许出现的字符进行编码,通常是编码以下字符"<"、">"、"&" 等。HtmlDecode: 刚好跟 HtmlEncode 相关,解码出来原本的字符。
str = str.Replace("&","&");