|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Custom HttpHandler and Server.TransferI've got a custom HttpHandler to process all requests for a given
extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really need to avoid the extra round-trip to the client. I've tried Passing the page name, the full URL, and the instance of the handler class to the Transfer method, but everything gets me the same error 500. Any help would be appreciated. Thanks, Bryan Hi Bryan,
We have reviewed this issue and are currently researching on it. We will update you ASAP. Thanks for your patience! Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Hi Bryan,
As for ASP.NET's Server.Transfer method, it can only help forward request between the pages or urls within the same asp.net webapplcation, we can not use Server.Transfer to direct the current request to a resource in different application or on other server. So what's the url you used in the Server.Transfer ? Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | From: bryan@newsgroups.nospam 68.253.212.158| Subject: Custom HttpHandler and Server.Transfer | Date: Fri, 23 Dec 2005 20:27:01 -0600 | Message-ID: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> | X-Newsreader: Forte Agent 3.1/32.783 | MIME-Version: 1.0 | Content-Type: text/plain; charset=us-ascii | Content-Transfer-Encoding: 7bit | Newsgroups: microsoft.public.dotnet.framework.aspnet | NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | Lines: 1 microsoft.public.dotnet.framework.aspnet:366884| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet | | I've got a custom HttpHandler to process all requests for a given | extension. It gets invoked OK, but if I try to do a Server.Transfer I | get an HttpException. A Response.Redirect works, but I really need to | avoid the extra round-trip to the client. | | I've tried Passing the page name, the full URL, and the instance of | the handler class to the Transfer method, but everything gets me the | same error 500. | | Any help would be appreciated. | | Thanks, | Bryan | Steven -
Thanks for the reply. The target of the Transfer is another page in the same app that should be handled by the same custom handler. The custom extension is set so that the handler gets invoked even if the "pages" are not pesent, and there is in fact no physical page for the target (nor is there for the source.) Cheers, Bryan On Mon, 26 Dec 2005 03:48:16 GMT, stch***@online.microsoft.com (Steven Cheng[MSFT]) wrote: Show quoteHide quote >Hi Bryan, > >As for ASP.NET's Server.Transfer method, it can only help forward request >between the pages or urls within the same asp.net webapplcation, we can not >use Server.Transfer to direct the current request to a resource in >different application or on other server. So what's the url you used in the >Server.Transfer ? > >Regards, > >Steven Cheng >Microsoft Online Support > >Get Secure! www.microsoft.com/security >(This posting is provided "AS IS", with no warranties, and confers no >rights.) > > >-------------------- >| From: bryan@newsgroups.nospam >| Subject: Custom HttpHandler and Server.Transfer >| Date: Fri, 23 Dec 2005 20:27:01 -0600 >| Message-ID: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> >| X-Newsreader: Forte Agent 3.1/32.783 >| MIME-Version: 1.0 >| Content-Type: text/plain; charset=us-ascii >| Content-Transfer-Encoding: 7bit >| Newsgroups: microsoft.public.dotnet.framework.aspnet >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net >68.253.212.158 >| Lines: 1 >| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl >| Xref: TK2MSFTNGXA02.phx.gbl >microsoft.public.dotnet.framework.aspnet:366884 >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet >| >| I've got a custom HttpHandler to process all requests for a given >| extension. It gets invoked OK, but if I try to do a Server.Transfer I >| get an HttpException. A Response.Redirect works, but I really need to >| avoid the extra round-trip to the client. >| >| I've tried Passing the page name, the full URL, and the instance of >| the handler class to the Transfer method, but everything gets me the >| same error 500. >| >| Any help would be appreciated. >| >| Thanks, >| Bryan >| Hi Bryan,
Thanks for your response. I've just performed some further test according to your scenario, I did reproduce the problem you encountered, and after some further research, it seems due to the HttpServerUtility.Transfer methods only addressing transfer to another Page handler, I've check the related code and found that when the runtime found the target handler is not a page hanlder, it'll throw exception.... So far, in addition to use Response.Redirect, you can also have a look at the HttpContext.RewritePath method which can help forward the internal request to another resource in same application,e.g: if(context.Request.QueryString["transfer"] != null) { context.RewritePath("test.sh?id=aa&test=bb&asp=111"); } Thanks & Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | From: bryan@newsgroups.nospam <bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl>| Subject: Re: Custom HttpHandler and Server.Transfer | Date: Mon, 26 Dec 2005 08:59:31 -0600 | Message-ID: <e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> | References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> | X-Newsreader: Forte Agent 3.1/32.783 68.253.212.158| MIME-Version: 1.0 | Content-Type: text/plain; charset=us-ascii | Content-Transfer-Encoding: 7bit | Newsgroups: microsoft.public.dotnet.framework.aspnet | NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | Lines: 1 microsoft.public.dotnet.framework.aspnet:367058| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet | | Steven - | Thanks for the reply. The target of the Transfer is another page in | the same app that should be handled by the same custom handler. The | custom extension is set so that the handler gets invoked even if the | "pages" are not pesent, and there is in fact no physical page for the | target (nor is there for the source.) | | Cheers, | Bryan | | On Mon, 26 Dec 2005 03:48:16 GMT, stch***@online.microsoft.com (Steven | Cheng[MSFT]) wrote: | | >Hi Bryan, | > | >As for ASP.NET's Server.Transfer method, it can only help forward request | >between the pages or urls within the same asp.net webapplcation, we can not | >use Server.Transfer to direct the current request to a resource in | >different application or on other server. So what's the url you used in the | >Server.Transfer ? | > | >Regards, | > | >Steven Cheng | >Microsoft Online Support | > | >Get Secure! www.microsoft.com/security | >(This posting is provided "AS IS", with no warranties, and confers no | >rights.) | > | > | >-------------------- | >| From: bryan@newsgroups.nospam | >| Subject: Custom HttpHandler and Server.Transfer | >| Date: Fri, 23 Dec 2005 20:27:01 -0600 | >| Message-ID: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> | >| X-Newsreader: Forte Agent 3.1/32.783 | >| MIME-Version: 1.0 | >| Content-Type: text/plain; charset=us-ascii | >| Content-Transfer-Encoding: 7bit | >| Newsgroups: microsoft.public.dotnet.framework.aspnet | >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | >68.253.212.158 | >| Lines: 1 | >| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl | >| Xref: TK2MSFTNGXA02.phx.gbl | >microsoft.public.dotnet.framework.aspnet:366884 | >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet | >| | >| I've got a custom HttpHandler to process all requests for a given | >| extension. It gets invoked OK, but if I try to do a Server.Transfer I | >| get an HttpException. A Response.Redirect works, but I really need to | >| avoid the extra round-trip to the client. | >| | >| I've tried Passing the page name, the full URL, and the instance of | >| the handler class to the Transfer method, but everything gets me the | >| same error 500. | >| | >| Any help would be appreciated. | >| | >| Thanks, | >| Bryan | >| | Steven-
Will rewrite path cause the transfer to handled entirely on the server, or will it still cause anther round trip to the client and back? Thanks again for all the help. Cheers, Bryan On Tue, 27 Dec 2005 05:24:45 GMT, stch***@online.microsoft.com (Steven Cheng[MSFT]) wrote: Show quoteHide quote >Hi Bryan, > >Thanks for your response. I've just performed some further test according >to your scenario, I did reproduce the problem you encountered, and after >some further research, it seems due to the HttpServerUtility.Transfer >methods only addressing transfer to another Page handler, I've check the >related code and found that when the runtime found the target handler is >not a page hanlder, it'll throw exception.... > >So far, in addition to use Response.Redirect, you can also have a look at >the HttpContext.RewritePath method which can help forward the internal >request to another resource in same application,e.g: > > if(context.Request.QueryString["transfer"] != null) > { > context.RewritePath("test.sh?id=aa&test=bb&asp=111"); > } > >Thanks & Regards, > >Steven Cheng >Microsoft Online Support > >Get Secure! www.microsoft.com/security >(This posting is provided "AS IS", with no warranties, and confers no >rights.) > > >-------------------- >| From: bryan@newsgroups.nospam >| Subject: Re: Custom HttpHandler and Server.Transfer >| Date: Mon, 26 Dec 2005 08:59:31 -0600 >| Message-ID: <e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> >| References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> ><bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl> >| X-Newsreader: Forte Agent 3.1/32.783 >| MIME-Version: 1.0 >| Content-Type: text/plain; charset=us-ascii >| Content-Transfer-Encoding: 7bit >| Newsgroups: microsoft.public.dotnet.framework.aspnet >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net >68.253.212.158 >| Lines: 1 >| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl >| Xref: TK2MSFTNGXA02.phx.gbl >microsoft.public.dotnet.framework.aspnet:367058 >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet >| >| Steven - >| Thanks for the reply. The target of the Transfer is another page in >| the same app that should be handled by the same custom handler. The >| custom extension is set so that the handler gets invoked even if the >| "pages" are not pesent, and there is in fact no physical page for the >| target (nor is there for the source.) >| >| Cheers, >| Bryan >| >| On Mon, 26 Dec 2005 03:48:16 GMT, stch***@online.microsoft.com (Steven >| Cheng[MSFT]) wrote: >| >| >Hi Bryan, >| > >| >As for ASP.NET's Server.Transfer method, it can only help forward >request >| >between the pages or urls within the same asp.net webapplcation, we can >not >| >use Server.Transfer to direct the current request to a resource in >| >different application or on other server. So what's the url you used in >the >| >Server.Transfer ? >| > >| >Regards, >| > >| >Steven Cheng >| >Microsoft Online Support >| > >| >Get Secure! www.microsoft.com/security >| >(This posting is provided "AS IS", with no warranties, and confers no >| >rights.) >| > >| > >| >-------------------- >| >| From: bryan@newsgroups.nospam >| >| Subject: Custom HttpHandler and Server.Transfer >| >| Date: Fri, 23 Dec 2005 20:27:01 -0600 >| >| Message-ID: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> >| >| X-Newsreader: Forte Agent 3.1/32.783 >| >| MIME-Version: 1.0 >| >| Content-Type: text/plain; charset=us-ascii >| >| Content-Transfer-Encoding: 7bit >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet >| >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net >| >68.253.212.158 >| >| Lines: 1 >| >| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl >| >| Xref: TK2MSFTNGXA02.phx.gbl >| >microsoft.public.dotnet.framework.aspnet:366884 >| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet >| >| >| >| I've got a custom HttpHandler to process all requests for a given >| >| extension. It gets invoked OK, but if I try to do a Server.Transfer I >| >| get an HttpException. A Response.Redirect works, but I really need to >| >| avoid the extra round-trip to the client. >| >| >| >| I've tried Passing the page name, the full URL, and the instance of >| >| the handler class to the Transfer method, but everything gets me the >| >| same error 500. >| >| >| >| Any help would be appreciated. >| >| >| >| Thanks, >| >| Bryan >| >| >| Hi Bryan,
Of course Context.RewritePath is a serverside operation which change the server side processing path for the current request. No roundtrip to client (the browser's address bar will remain the original one....). Usuallly it is used for Url Rewriting in asp.net application (to provide static look url which is search engine friendly...). Here is a article discuss this: #URL Rewriting in ASP.NET http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html /urlrewriting.asp Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | From: bryan@newsgroups.nospam <bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl> | Subject: Re: Custom HttpHandler and Server.Transfer | Date: Tue, 27 Dec 2005 07:37:55 -0600 | Message-ID: <6pg2r15c20o9t1bp1a26fudbft5onmv***@4ax.com> | References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> <e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> <NujKeXqCGHA.1***@TK2MSFTNGXA02.phx.gbl> | X-Newsreader: Forte Agent 3.1/32.783 68.253.212.158| MIME-Version: 1.0 | Content-Type: text/plain; charset=us-ascii | Content-Transfer-Encoding: 7bit | Newsgroups: microsoft.public.dotnet.framework.aspnet | NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | Lines: 1 microsoft.public.dotnet.framework.aspnet:367136| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl| | Steven- | Will rewrite path cause the transfer to handled entirely on the | server, or will it still cause anther round trip to the client and | back? | | Thanks again for all the help. | | Cheers, | Bryan | | On Tue, 27 Dec 2005 05:24:45 GMT, stch***@online.microsoft.com (Steven | Cheng[MSFT]) wrote: | | >Hi Bryan, | > | >Thanks for your response. I've just performed some further test according | >to your scenario, I did reproduce the problem you encountered, and after | >some further research, it seems due to the HttpServerUtility.Transfer | >methods only addressing transfer to another Page handler, I've check the | >related code and found that when the runtime found the target handler is | >not a page hanlder, it'll throw exception.... | > | >So far, in addition to use Response.Redirect, you can also have a look at | >the HttpContext.RewritePath method which can help forward the internal | >request to another resource in same application,e.g: | > | > if(context.Request.QueryString["transfer"] != null) | > { | > context.RewritePath("test.sh?id=aa&test=bb&asp=111"); | > } | > | >Thanks & Regards, | > | >Steven Cheng | >Microsoft Online Support | > | >Get Secure! www.microsoft.com/security | >(This posting is provided "AS IS", with no warranties, and confers no | >rights.) | > | > | >-------------------- | >| From: bryan@newsgroups.nospam | >| Subject: Re: Custom HttpHandler and Server.Transfer | >| Date: Mon, 26 Dec 2005 08:59:31 -0600 | >| Message-ID: <e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> | >| References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> | ><bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl> | >| X-Newsreader: Forte Agent 3.1/32.783 | >| MIME-Version: 1.0 | >| Content-Type: text/plain; charset=us-ascii | >| Content-Transfer-Encoding: 7bit | >| Newsgroups: microsoft.public.dotnet.framework.aspnet | >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | >68.253.212.158 | >| Lines: 1 | >| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl | >| Xref: TK2MSFTNGXA02.phx.gbl | >microsoft.public.dotnet.framework.aspnet:367058 | >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet | >| | >| Steven - | >| Thanks for the reply. The target of the Transfer is another page in | >| the same app that should be handled by the same custom handler. The | >| custom extension is set so that the handler gets invoked even if the | >| "pages" are not pesent, and there is in fact no physical page for the | >| target (nor is there for the source.) | >| | >| Cheers, | >| Bryan | >| | >| On Mon, 26 Dec 2005 03:48:16 GMT, stch***@online.microsoft.com (Steven | >| Cheng[MSFT]) wrote: | >| | >| >Hi Bryan, | >| > | >| >As for ASP.NET's Server.Transfer method, it can only help forward | >request | >| >between the pages or urls within the same asp.net webapplcation, we can | >not | >| >use Server.Transfer to direct the current request to a resource in | >| >different application or on other server. So what's the url you used in | >the | >| >Server.Transfer ? | >| > | >| >Regards, | >| > | >| >Steven Cheng | >| >Microsoft Online Support | >| > | >| >Get Secure! www.microsoft.com/security | >| >(This posting is provided "AS IS", with no warranties, and confers no | >| >rights.) | >| > | >| > | >| >-------------------- | >| >| From: bryan@newsgroups.nospam | >| >| Subject: Custom HttpHandler and Server.Transfer | >| >| Date: Fri, 23 Dec 2005 20:27:01 -0600 | >| >| Message-ID: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> | >| >| X-Newsreader: Forte Agent 3.1/32.783 | >| >| MIME-Version: 1.0 | >| >| Content-Type: text/plain; charset=us-ascii | >| >| Content-Transfer-Encoding: 7bit | >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet | >| >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | >| >68.253.212.158 | >| >| Lines: 1 | >| >| Path: Show quoteHide quote | >| >| Xref: TK2MSFTNGXA02.phx.gbl | >| >microsoft.public.dotnet.framework.aspnet:366884 | >| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet | >| >| | >| >| I've got a custom HttpHandler to process all requests for a given | >| >| extension. It gets invoked OK, but if I try to do a Server.Transfer I | >| >| get an HttpException. A Response.Redirect works, but I really need to | >| >| avoid the extra round-trip to the client. | >| >| | >| >| I've tried Passing the page name, the full URL, and the instance of | >| >| the handler class to the Transfer method, but everything gets me the | >| >| same error 500. | >| >| | >| >| Any help would be appreciated. | >| >| | >| >| Thanks, | >| >| Bryan | >| >| | >| | Steven -
RewritePath won't work. My custom handler is associated with an extension that does not require the actual files to be present. So I rewrite the path, but there is no page there, so an empty file is getting returned. I don't see my custom handler getting invoked on the RewritePath call, but I have not had the chance to digg too deeply into this. -Bryan On Wed, 28 Dec 2005 01:25:09 GMT, stch***@online.microsoft.com (Steven Cheng[MSFT]) wrote: Show quoteHide quote >Hi Bryan, > >Of course Context.RewritePath is a serverside operation which change the >server side processing path for the current request. No roundtrip to client >(the browser's address bar will remain the original one....). Usuallly it >is used for Url Rewriting in asp.net application (to provide static look >url which is search engine friendly...). Here is a article discuss this: > >#URL Rewriting in ASP.NET >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html >/urlrewriting.asp > >Regards, > >Steven Cheng >Microsoft Online Support > >Get Secure! www.microsoft.com/security >(This posting is provided "AS IS", with no warranties, and confers no >rights.) > >-------------------- >| From: bryan@newsgroups.nospam >| Subject: Re: Custom HttpHandler and Server.Transfer >| Date: Tue, 27 Dec 2005 07:37:55 -0600 >| Message-ID: <6pg2r15c20o9t1bp1a26fudbft5onmv***@4ax.com> >| References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> ><bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl> ><e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> ><NujKeXqCGHA.1***@TK2MSFTNGXA02.phx.gbl> >| X-Newsreader: Forte Agent 3.1/32.783 >| MIME-Version: 1.0 >| Content-Type: text/plain; charset=us-ascii >| Content-Transfer-Encoding: 7bit >| Newsgroups: microsoft.public.dotnet.framework.aspnet >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net >68.253.212.158 >| Lines: 1 >| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl >| Xref: TK2MSFTNGXA02.phx.gbl >microsoft.public.dotnet.framework.aspnet:367136 >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet >| >| Steven- >| Will rewrite path cause the transfer to handled entirely on the >| server, or will it still cause anther round trip to the client and >| back? >| >| Thanks again for all the help. >| >| Cheers, >| Bryan >| >| On Tue, 27 Dec 2005 05:24:45 GMT, stch***@online.microsoft.com (Steven >| Cheng[MSFT]) wrote: >| >| >Hi Bryan, >| > >| >Thanks for your response. I've just performed some further test >according >| >to your scenario, I did reproduce the problem you encountered, and after >| >some further research, it seems due to the HttpServerUtility.Transfer >| >methods only addressing transfer to another Page handler, I've check the >| >related code and found that when the runtime found the target handler is >| >not a page hanlder, it'll throw exception.... >| > >| >So far, in addition to use Response.Redirect, you can also have a look >at >| >the HttpContext.RewritePath method which can help forward the internal >| >request to another resource in same application,e.g: >| > >| > if(context.Request.QueryString["transfer"] != null) >| > { >| > context.RewritePath("test.sh?id=aa&test=bb&asp=111"); >| > } >| > >| >Thanks & Regards, >| > >| >Steven Cheng >| >Microsoft Online Support >| > >| >Get Secure! www.microsoft.com/security >| >(This posting is provided "AS IS", with no warranties, and confers no >| >rights.) >| > >| > >| >-------------------- >| >| From: bryan@newsgroups.nospam >| >| Subject: Re: Custom HttpHandler and Server.Transfer >| >| Date: Mon, 26 Dec 2005 08:59:31 -0600 >| >| Message-ID: <e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> >| >| References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> >| ><bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl> >| >| X-Newsreader: Forte Agent 3.1/32.783 >| >| MIME-Version: 1.0 >| >| Content-Type: text/plain; charset=us-ascii >| >| Content-Transfer-Encoding: 7bit >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet >| >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net >| >68.253.212.158 >| >| Lines: 1 >| >| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl >| >| Xref: TK2MSFTNGXA02.phx.gbl >| >microsoft.public.dotnet.framework.aspnet:367058 >| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet >| >| >| >| Steven - >| >| Thanks for the reply. The target of the Transfer is another page in >| >| the same app that should be handled by the same custom handler. The >| >| custom extension is set so that the handler gets invoked even if the >| >| "pages" are not pesent, and there is in fact no physical page for the >| >| target (nor is there for the source.) >| >| >| >| Cheers, >| >| Bryan >| >| >| >| On Mon, 26 Dec 2005 03:48:16 GMT, stch***@online.microsoft.com (Steven >| >| Cheng[MSFT]) wrote: >| >| >| >| >Hi Bryan, >| >| > >| >| >As for ASP.NET's Server.Transfer method, it can only help forward >| >request >| >| >between the pages or urls within the same asp.net webapplcation, we >can >| >not >| >| >use Server.Transfer to direct the current request to a resource in >| >| >different application or on other server. So what's the url you used >in >| >the >| >| >Server.Transfer ? >| >| > >| >| >Regards, >| >| > >| >| >Steven Cheng >| >| >Microsoft Online Support >| >| > >| >| >Get Secure! www.microsoft.com/security >| >| >(This posting is provided "AS IS", with no warranties, and confers no >| >| >rights.) >| >| > >| >| > >| >| >-------------------- >| >| >| From: bryan@newsgroups.nospam >| >| >| Subject: Custom HttpHandler and Server.Transfer >| >| >| Date: Fri, 23 Dec 2005 20:27:01 -0600 >| >| >| Message-ID: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> >| >| >| X-Newsreader: Forte Agent 3.1/32.783 >| >| >| MIME-Version: 1.0 >| >| >| Content-Type: text/plain; charset=us-ascii >| >| >| Content-Transfer-Encoding: 7bit >| >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet >| >| >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net >| >| >68.253.212.158 >| >| >| Lines: 1 >| >| >| Path: >TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl >| >| >| Xref: TK2MSFTNGXA02.phx.gbl >| >| >microsoft.public.dotnet.framework.aspnet:366884 >| >| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet >| >| >| >| >| >| I've got a custom HttpHandler to process all requests for a given >| >| >| extension. It gets invoked OK, but if I try to do a Server.Transfer >I >| >| >| get an HttpException. A Response.Redirect works, but I really need >to >| >| >| avoid the extra round-trip to the client. >| >| >| >| >| >| I've tried Passing the page name, the full URL, and the instance of >| >| >| the handler class to the Transfer method, but everything gets me the >| >| >| same error 500. >| >| >| >| >| >| Any help would be appreciated. >| >| >| >| >| >| Thanks, >| >| >| Bryan >| >| >| >| >| >| Thanks for your Bryan,
I'm sorry for the HttpContext.RewritePath, I've rechecked it and it won't work in handler's ProcessRequest method (it's too later at that time...), generally it is used in some intial events in the asp.net pipeline like (BeginRequest.....).... And for Server.Transfer, I've consult our dev engineer and seems it is a by design limitation that Server.Transfer can only be used to redirect to a page handler. Here is the original description from the dev guys: ================== Server.Transfer means ¡®execute this request using another handler¡¯ which works fine for pages because pages have handler per URL. In case of web services (and other handler factories) we get the same handler for all URLs and thus Server.Transfer would lead to infinite recursion. So it really only works for pages. ================== So far I think we may need to use response.Redirect for such redircting.... Thanks for your understanding, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | From: bryan@newsgroups.nospam <bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl> | Subject: Re: Custom HttpHandler and Server.Transfer | Date: Thu, 29 Dec 2005 09:19:35 -0600 | Message-ID: <kgv7r1t8lsd203q9ntkhvtvqh4ujnei***@4ax.com> | References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> <e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> <NujKeXqCGHA.1***@TK2MSFTNGXA02.phx.gbl> <6pg2r15c20o9t1bp1a26fudbft5onmv***@4ax.com> <DHseQ20CGHA.1***@TK2MSFTNGXA02.phx.gbl> | X-Newsreader: Forte Agent 3.1/32.783 68.253.212.158| MIME-Version: 1.0 | Content-Type: text/plain; charset=us-ascii | Content-Transfer-Encoding: 7bit | Newsgroups: microsoft.public.dotnet.framework.aspnet | NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | Lines: 1 microsoft.public.dotnet.framework.aspnet:367534| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl | Xref: TK2MSFTNGXA02.phx.gbl Show quoteHide quote | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl| | Steven - | RewritePath won't work. My custom handler is associated with an | extension that does not require the actual files to be present. So I | rewrite the path, but there is no page there, so an empty file is | getting returned. I don't see my custom handler getting invoked on the | RewritePath call, but I have not had the chance to digg too deeply | into this. | | -Bryan | | On Wed, 28 Dec 2005 01:25:09 GMT, stch***@online.microsoft.com (Steven | Cheng[MSFT]) wrote: | | >Hi Bryan, | > | >Of course Context.RewritePath is a serverside operation which change the | >server side processing path for the current request. No roundtrip to client | >(the browser's address bar will remain the original one....). Usuallly it | >is used for Url Rewriting in asp.net application (to provide static look | >url which is search engine friendly...). Here is a article discuss this: | > | >#URL Rewriting in ASP.NET | >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/htm l | >/urlrewriting.asp | > | >Regards, | > | >Steven Cheng | >Microsoft Online Support | > | >Get Secure! www.microsoft.com/security | >(This posting is provided "AS IS", with no warranties, and confers no | >rights.) | > | >-------------------- | >| From: bryan@newsgroups.nospam | >| Subject: Re: Custom HttpHandler and Server.Transfer | >| Date: Tue, 27 Dec 2005 07:37:55 -0600 | >| Message-ID: <6pg2r15c20o9t1bp1a26fudbft5onmv***@4ax.com> | >| References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> | ><bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl> | ><e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> | ><NujKeXqCGHA.1***@TK2MSFTNGXA02.phx.gbl> | >| X-Newsreader: Forte Agent 3.1/32.783 | >| MIME-Version: 1.0 | >| Content-Type: text/plain; charset=us-ascii | >| Content-Transfer-Encoding: 7bit | >| Newsgroups: microsoft.public.dotnet.framework.aspnet | >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | >68.253.212.158 | >| Lines: 1 | >| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl | >| Xref: TK2MSFTNGXA02.phx.gbl | >microsoft.public.dotnet.framework.aspnet:367136 | >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet | >| | >| Steven- | >| Will rewrite path cause the transfer to handled entirely on the | >| server, or will it still cause anther round trip to the client and | >| back? | >| | >| Thanks again for all the help. | >| | >| Cheers, | >| Bryan | >| | >| On Tue, 27 Dec 2005 05:24:45 GMT, stch***@online.microsoft.com (Steven | >| Cheng[MSFT]) wrote: | >| | >| >Hi Bryan, | >| > | >| >Thanks for your response. I've just performed some further test | >according | >| >to your scenario, I did reproduce the problem you encountered, and after | >| >some further research, it seems due to the HttpServerUtility.Transfer | >| >methods only addressing transfer to another Page handler, I've check the | >| >related code and found that when the runtime found the target handler is | >| >not a page hanlder, it'll throw exception.... | >| > | >| >So far, in addition to use Response.Redirect, you can also have a look | >at | >| >the HttpContext.RewritePath method which can help forward the internal | >| >request to another resource in same application,e.g: | >| > | >| > if(context.Request.QueryString["transfer"] != null) | >| > { | >| > context.RewritePath("test.sh?id=aa&test=bb&asp=111"); | >| > } | >| > | >| >Thanks & Regards, | >| > | >| >Steven Cheng | >| >Microsoft Online Support | >| > | >| >Get Secure! www.microsoft.com/security | >| >(This posting is provided "AS IS", with no warranties, and confers no | >| >rights.) | >| > | >| > | >| >-------------------- | >| >| From: bryan@newsgroups.nospam | >| >| Subject: Re: Custom HttpHandler and Server.Transfer | >| >| Date: Mon, 26 Dec 2005 08:59:31 -0600 | >| >| Message-ID: <e510r11pfkrbpl9me3fsrgm4u3ut9g7***@4ax.com> | >| >| References: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> | >| ><bBKS58cCGHA.3***@TK2MSFTNGXA02.phx.gbl> | >| >| X-Newsreader: Forte Agent 3.1/32.783 | >| >| MIME-Version: 1.0 | >| >| Content-Type: text/plain; charset=us-ascii | >| >| Content-Transfer-Encoding: 7bit | >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet | >| >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | >| >68.253.212.158 | >| >| Lines: 1 | >| >| Path: Show quoteHide quote | >| >| Xref: TK2MSFTNGXA02.phx.gbl | >| >microsoft.public.dotnet.framework.aspnet:367058 | >| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet | >| >| | >| >| Steven - | >| >| Thanks for the reply. The target of the Transfer is another page in | >| >| the same app that should be handled by the same custom handler. The | >| >| custom extension is set so that the handler gets invoked even if the | >| >| "pages" are not pesent, and there is in fact no physical page for the | >| >| target (nor is there for the source.) | >| >| | >| >| Cheers, | >| >| Bryan | >| >| | >| >| On Mon, 26 Dec 2005 03:48:16 GMT, stch***@online.microsoft.com (Steven | >| >| Cheng[MSFT]) wrote: | >| >| | >| >| >Hi Bryan, | >| >| > | >| >| >As for ASP.NET's Server.Transfer method, it can only help forward | >| >request | >| >| >between the pages or urls within the same asp.net webapplcation, we | >can | >| >not | >| >| >use Server.Transfer to direct the current request to a resource in | >| >| >different application or on other server. So what's the url you used | >in | >| >the | >| >| >Server.Transfer ? | >| >| > | >| >| >Regards, | >| >| > | >| >| >Steven Cheng | >| >| >Microsoft Online Support | >| >| > | >| >| >Get Secure! www.microsoft.com/security | >| >| >(This posting is provided "AS IS", with no warranties, and confers no | >| >| >rights.) | >| >| > | >| >| > | >| >| >-------------------- | >| >| >| From: bryan@newsgroups.nospam | >| >| >| Subject: Custom HttpHandler and Server.Transfer | >| >| >| Date: Fri, 23 Dec 2005 20:27:01 -0600 | >| >| >| Message-ID: <6acpq1h5lhpljps8k1u1vhuicadj5s5***@4ax.com> | >| >| >| X-Newsreader: Forte Agent 3.1/32.783 | >| >| >| MIME-Version: 1.0 | >| >| >| Content-Type: text/plain; charset=us-ascii | >| >| >| Content-Transfer-Encoding: 7bit | >| >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet | >| >| >| NNTP-Posting-Host: adsl-68-253-212-158.dsl.emhril.ameritech.net | >| >| >68.253.212.158 | >| >| >| Lines: 1 | >| >| >| Path: | >TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl | >| >| >| Xref: TK2MSFTNGXA02.phx.gbl | >| >| >microsoft.public.dotnet.framework.aspnet:366884 | >| >| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet | >| >| >| | >| >| >| I've got a custom HttpHandler to process all requests for a given | >| >| >| extension. It gets invoked OK, but if I try to do a Server.Transfer | >I | >| >| >| get an HttpException. A Response.Redirect works, but I really need | >to | >| >| >| avoid the extra round-trip to the client. | >| >| >| | >| >| >| I've tried Passing the page name, the full URL, and the instance of | >| >| >| the handler class to the Transfer method, but everything gets me the | >| >| >| same error 500. | >| >| >| | >| >| >| Any help would be appreciated. | >| >| >| | >| >| >| Thanks, | >| >| >| Bryan | >| >| >| | >| >| | >| |
Other interesting topics
CodeBehind File not getting executed
Application-wide Server.Transfer Does Not Invoke IsPostBack in .NET Framework 1.1 How do I debug this... HtmlImage and asp:Image servent onclick event Help: Javascript for checking user Protecting files .aspx / .ascx in Visual Studio 2005 Coordination of projects Ridiculously Slow SqlServer2005 Sorting? |
|||||||||||||||||||||||