How to get the QueryString from an ashx file?
Asked Answered
J

1

14

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.

Jaynajayne answered 3/11, 2010 at 10:14 Comment(2)
Never had a problem with this - suggest you post your code and your handler configOffprint
It's a lot of files each function calling another so I am still trying to catch it from the beginning. I guess it's called from some javascript!Jaynajayne
L
28

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"];
}
Lapp answered 3/11, 2010 at 12:29 Comment(4)
Thanks! But how is the request for ashx made? And where usually?Jaynajayne
@Ahmad: What do you mean? The request is made by the client, recieved by the webserver, and passed to the ASP.NET pipeline which hopefully has appropriate web.config to direct the request to your IHttpHandlerOffprint
I mean how does the request to the ashx file look like? I've never used it before and it's not my code. I'm just trying to fix some bug in someone else's codeJaynajayne
@AhmadFarid, do you mean this? webcam.set_api_url('KameraHandler.ashx?patientID=' + patientID);Deliquescence

© 2022 - 2024 — McMap. All rights reserved.