gkket 发表于 2021-8-16 20:48:52

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}


wx_GWWCJWaG 发表于 2021-8-16 21:28:55

太生气了,无法HOLD啦 >_<......

lqc2856 发表于 2025-11-13 02:14:35

求个链接 / 教程,楼主好人一生平安~

wx_T6llk190 发表于 2025-11-13 03:44:05

原来还有这种操作,长见识了!

无序 发表于 2025-11-15 11:58:57

来凑个热闹,增加点人气~

hjx123456 发表于 2025-11-15 12:05:37

楼主太会说了,字字句句都在理

陈艾丽 发表于 2025-11-15 12:05:45

同款经历!我当初也这么过来的😂

hjx123456 发表于 2025-11-15 12:08:42

不请自来,就想夸一句:太顶了!

wx_Lh3GY7Wv 发表于 2025-11-15 12:10:17

这波反向操作,我属实没想到!

jianminzhang_wh 发表于 2025-11-15 12:13:00

路过打卡,为优质内容疯狂打 call
页: [1] 2
查看完整版本: C# ashx页面获取URL参数