C# ashx页面获取URL参数
C# ashx页面获取URL参数后台获取代码public void ProcessRequest(HttpContext context){context.Response.ContentType = "text/plain";context.Response.Write("Hello World");// 当前页面完整URL为:http://www.hicsharp.com/index.ashx?keyword=test&page=1// 1.获取页面完整的URL,协议名+域名+站点名+文件名+参数string url = context.Request.Url.ToString();// 结果:http://www.hicsharp.com/index.ashx?keyword=test&page=1// 2.获取页面完整的URL,协议名+域名+站点名+文件名+参数string absoluteUri = context.Request.Url.AbsoluteUri;// 结果:http://www.hicsharp.com/index.ashx?keyword=test&page=1// 3.获取域名或主机,不包含端口string host = context.Request.Url.Host;// 结果:www.hicsharp.com// 4.获取域名或主机, 包含端口, 如果端口默认是80则不显示string authority = context.Request.Url.Authority;// 结果:www.hicsharp.com:8080// 5.获取请求页面string pathAndQuery = context.Request.Url.PathAndQuery;// 结果:/index.ashx?keyword=test&page=1// 6.获取请求页面的真实地址, 如果使用伪静态, 可以获取伪静态指向的页面// http://www.hicsharp.com/article/123.html// http://www.hicsharp.com/article/details.ashx?id=123string rawUrl = context.Request.RawUrl.ToString();// 结果:/article/123.html// 7.获取请求参数string query = context.Request.Url.Query;// 结果:?keyword=test&page=1}太生气了,无法HOLD啦 >_<......
求个链接 / 教程,楼主好人一生平安~ 原来还有这种操作,长见识了! 来凑个热闹,增加点人气~ 楼主太会说了,字字句句都在理 同款经历!我当初也这么过来的😂 不请自来,就想夸一句:太顶了! 这波反向操作,我属实没想到! 路过打卡,为优质内容疯狂打 call
页:
[1]
2