![]() |
|
|
|||||||
![]() |
ASP Net - How to get a handler for a path |
|
|
Thread Tools | Search this Thread |
|
|
#11 |
|
Hi,
Thank you for your reply. Allen Chen [MSFT] wrote: > Is it possible to send a HTTP reqeust to that given path in your > "sub-request like feature"? By checking the HTTP response we can know > whether it's handled by your handler. (in your HttpHandler, you can add > specific HTTP header or return specific content in response to notify that > it's handled by your handler) > > You can use WebClient to request that path and check the response. Can it > solve this issue? What I want to avoid is executing handlers other than mine. In fact I don't have to execute my handler but even if I execute it that is not a problem. By making a request I would execute any handler on that URL. Marvin Marvin Landman |
|
|
|
|
#12 |
|
Posts: n/a
|
Hi Marvin,
>What I want to avoid is executing handlers other than mine. In fact I >don't have to execute my handler but even if I execute it that is not a >problem. By making a request I would execute any handler on that URL. Thanks for your update. I believe we can move forward if you could clarify this point: You mentioned: >because my system has a sub-request like feature >that needs this information. What is your "system"? Is it an ASP.NET application? Does it run on the web server or another machine? We probably can work out a solution if this point is clarified. Regards, Allen Chen Microsoft Online Support Allen Chen [MSFT] |
|
|
|
#13 |
|
Posts: n/a
|
Allen Chen [MSFT] wrote:
>> because my system has a sub-request like feature >> that needs this information. > > What is your "system"? Is it an ASP.NET application? Does it run on the web > server or another machine? Thank your for your response. This is a development framework based on the ASP.NET infrastructure and intended to be used by web applications. Marvin Marvin Landman |
|
|
|
#14 |
|
Posts: n/a
|
Hi Marvin,
>This is a development framework based on the ASP.NET infrastructure and >intended to be used by web applications. Thanks for update. Do you mean you want to check the path in the same application? If it is you probably can try the following approach if reflection is an acceptable option: protected void Page_Load(object sender, EventArgs e) { // Given path string vp = "~/1.allenchen"; var virtualpath = Assembly.GetAssembly(typeof(HttpApplication)).Crea teInstance("System.Web.Vir tualPath", false, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { vp }, CultureInfo.CurrentCulture, null); // Use MapHttpHandler method for classic mode, MapIntegratedHttpHandler for integrated mode // If you test it in ASP.NET Web Development server it may throw exception. // Please publish it to IIS and use Integriated mode to test MethodInfo mi = HttpContext.Current.ApplicationInstance.GetType(). GetMethod("MapIntegratedHt tpHandler", BindingFlags.Instance | BindingFlags.NonPublic); var o = mi.Invoke(HttpContext.Current.ApplicationInstance, new object[] { HttpContext.Current, "GET", virtualpath, Request.ServerVariables["PATH_TRANSLATED"], false,false }); if (!(o is MyHandler)) { throw new Exception("Not handled by MyHandler"); } } Please test it to see if it can solve this issue. Regards, Allen Chen Microsoft Online Support Allen Chen [MSFT] |
|
|
|
#15 |
|
Posts: n/a
|
Hi Marvin,
>This is a development framework based on the ASP.NET infrastructure and >intended to be used by web applications. Can my suggestion solve this issue? Regards, Allen Chen Microsoft Online Support Allen Chen [MSFT] |
|
|
|
#16 |
|
Posts: n/a
|
Allen Chen [MSFT] wrote:
>> This is a development framework based on the ASP.NET infrastructure and >> intended to be used by web applications. > > Can my suggestion solve this issue? I was busy lately but now I got some time for evaluating your suggestion. Although I'm not happy that I have to rely on implementation details the solution perfeclty fits my needs. Thank you very much. Regards, Marvin Marvin Landman |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Catching Google Search Keywords Using Http Handler Class | nagaraj309 | Software | 0 | 12-02-2008 06:43 AM |
| example of Server.Transfer and Context Handler | hanusoft | Software | 0 | 09-22-2007 07:44 AM |