Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - How to get a handler for a path

 
Thread Tools Search this Thread
Old 11-02-2009, 05:47 PM   #11
Default Re: How to get a handler for a path


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
  Reply With Quote
Old 11-04-2009, 05:01 AM   #12
Allen Chen [MSFT]
 
Posts: n/a
Default Re: How to get a handler for a path
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]
  Reply With Quote
Old 11-04-2009, 04:15 PM   #13
Marvin Landman
 
Posts: n/a
Default Re: How to get a handler for a path
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
  Reply With Quote
Old 11-05-2009, 07:09 AM   #14
Allen Chen [MSFT]
 
Posts: n/a
Default Re: How to get a handler for a path
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]
  Reply With Quote
Old 11-11-2009, 03:43 AM   #15
Allen Chen [MSFT]
 
Posts: n/a
Default Re: How to get a handler for a path
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]
  Reply With Quote
Old 11-11-2009, 08:59 AM   #16
Marvin Landman
 
Posts: n/a
Default Re: How to get a handler for a path
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46