首页 新闻 会员 周边

在ashx中 怎么获取url

0
悬赏园豆:60 [已解决问题] 解决于 2014-08-14 12:38

比方说这样一个页面URL为 http://localhost:61514/test.aspx?Id=123

在后台获取  Id= Request["Id"] as string 是正常的,但是在ashx 页面不行。

HttpRequest request = System.Web.HttpContext.Current.Request;
            string Id = request.QueryString["Id"].ToString();

这个不行。

 string id= Request.QueryString["Id"].ToString()

也不行

亦有哭亦有笑的主页 亦有哭亦有笑 | 初学一级 | 园豆:5
提问于:2014-08-14 11:52
< >
分享
最佳答案
0

不知道楼主知不知道有个属性叫

UrlReferrer

Gets information about the URL of the client's previous request that linked to the current URL.

http://msdn.microsoft.com/en-us/library/system.web.httprequest_properties(v=vs.110).aspx

收获园豆:60
爱编程的大叔 | 高人七级 |园豆:30839 | 2014-08-14 12:24

我刚解决 和你思路差不多

 HttpRequest request = System.Web.HttpContext.Current.Request;
            Uri dsd = request.UrlReferrer;
            string a1 = dsd.Query.ToString();
            formId = a1.Substring(8);
亦有哭亦有笑 | 园豆:5 (初学一级) | 2014-08-14 12:37
其他回答(2)
0

你要请求http://localhost:61514/test.ashx?Id=123

dudu | 园豆:30994 (高人七级) | 2014-08-14 11:55

不是啊,这个页面是test.aspx 。post到XXX.ashx一般处理程序中,我要是的test.aspx的url

 $.post("handler/XXX.ashx", {
                    "val": "22",
                   
                },function (data) {
                     
                })

 

支持(0) 反对(0) 亦有哭亦有笑 | 园豆:5 (初学一级) | 2014-08-14 11:59
0

ashx 页面里有context,所以可以直接写context.Request.Form["Id"];

慢慢摸索 | 园豆:206 (菜鸟二级) | 2016-02-20 00:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册