Net 常用代码

循环输出cookie信息

for (int i = 0; i < Request.Cookies.Count; i++)
{
HttpCookie cookies
= Request.Cookies[i];
Response.Write(
"name=" + cookies.Name + "<br>");
if (cookies.HasKeys)
{
System.Collections.Specialized.NameValueCollection Namecall
= cookies.Values;
for (int j = 0; j < Namecall.Count; j++)
{
Response.Write(
"子键名=" + Namecall.AllKeys[j] + "<br/>");
Response.Write(
"子键值=" + Namecall[j] + "<br/>");
}
}
else
{
Response.Write(
"value=" + cookies.Value + "<br/>");
}
}

第二种代码着色!

for (int i = 0; i < Request.Cookies.Count; i++)
        {
            HttpCookie cookies = Request.Cookies[i];
            Response.Write("name=" + cookies.Name + "<br>");
            if (cookies.HasKeys)
            {
                System.Collections.Specialized.NameValueCollection Namecall = cookies.Values;
                for (int j = 0; j < Namecall.Count; j++)
                {
                    Response.Write("子键名=" + Namecall.AllKeys[j] + "<br/>");
                    Response.Write("子键值=" + Namecall[j] + "<br/>");
                }
            }
            else
            {
                Response.Write("value=" + cookies.Value + "<br/>");
            }
        }
System.Web.HttpContext.Current.Server.MapPath()
System.Web.HttpContext.Current.Session
System.Web.HttpContext.Current.Response
string spath = HttpContext.Current.Request.Path; /productlist.aspx
HttpContext.Current.Request.UrlReferrer//获取上一页面地址
Context.Request.UserHostAddress
原文地址:https://www.cnblogs.com/neve/p/1997754.html