开发者

How to get the QueryString from an ashx file?

开发者 https://www.devze.com 2023-01-23 01:35 出处:网络
There is an ashx file containing \"ProcessRequest(Http开发者_JAVA技巧Context context)\" method which gets triggered automatically. When and how does it get fired?

There is an ashx file containing "ProcessRequest(Http开发者_JAVA技巧Context 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.


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

public void ProcessRequest (HttpContext context) 
{
    string ID = context.Request.QueryString["ID"];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消