如何从 ashx 文件中获取查询字符串?
有一个 ashx 文件包含自动触发的“ProcessRequest(HttpContext context)”方法。它何时以及如何被解雇? 另一个问题,当我在这个文件中时如何获取当前的QueryString?当我输入“context.Request.QueryString
”时,它说它为空或空,尽管地址有参数。
There is an ashx file containing "ProcessRequest(HttpContext context)
" method which gets triggered automatically. When and how does it get fired?
Another question, How can I get the current QueryString when I am inside this file? When I type "context.Request.QueryString
" it says it's null or empty although the address have arguments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当发出对 ashx 文件的请求时,将调用 ProcessRequest 方法。传入 http 上下文对象是为了能够访问查询字符串、标头等内容。
回复:查询字符串访问:
只要在查询字符串上传递“ID”,以下内容就可以工作。
http://example.com/MyHandler.ashx?ID=12345
The ProcessRequest method is called when a request for the ashx file is made. The http context object is passed in to enable access to the stuff like the querystring, headers, etc.
Re: querystring access:
The following will work as long as "ID" is passed on the querystring.
http://example.com/MyHandler.ashx?ID=12345