|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Server.Execute & HttpHandlerMy problem is that when I am trying to use
Server.Execute("Somehandler.ashx") I am getting HttpException. [HttpException (0x80004005): Error executing child request for Somehandler.ashx.] System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +3179617 System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm) +747 System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) +56 System.Web.HttpServerUtility.Transfer(String path) +26 According to the documentation HttpServerUtilty.Execute/Transfer only works
with pages... It simply may not work with handlers, because the redirect is occurring from within the Page Handler framework. If you want to redirect to a handler you need a physical redirect with Response.Redirect(). +++ Rick --- Show quote "Sam" <f**@tempuri.org> wrote in message news:uQSa$XhAGHA.2736@TK2MSFTNGP11.phx.gbl... > My problem is that when I am trying to use > Server.Execute("Somehandler.ashx") I am getting HttpException. > > [HttpException (0x80004005): Error executing child request for > Somehandler.ashx.] > System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, > TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, > VirtualPath path, VirtualPath filePath, String physPath, Exception error, > String queryStringOverride) +3179617 > System.Web.HttpServerUtility.Execute(String path, TextWriter writer, > Boolean preserveForm) +747 > System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) > +56 > System.Web.HttpServerUtility.Transfer(String path) +26 Rick Strahl [MVP] wrote:
> According to the documentation HttpServerUtilty.Execute/Transfer only works I need to save Context.Items and it's impossible to redirect. Anyway my > with pages... It simply may not work with handlers, because the redirect is > occurring from within the Page Handler framework. If you want to redirect to > a handler you need a physical redirect with Response.Redirect(). > > +++ Rick --- > application need only Server.Execute. Quote from documentation: "Executes the handler for the specified virtual path in the context of the current request." I trust, there is no reason to prohibit IHttpHanlder derived classes. See Reflected code of HttpServerUtility.ExecuteInternal: .... else if (!(handler is Page)) { error = new HttpException(0x194, string.Empty); } .... handler.ProcessRequest(...) // BUT It's only for Page instances ((( .... object[] objArray2 = new object[] { handler.GetType().ToString() } ; throw new HttpException(SR.GetString("Error_executing_child_request_for_handler", objArray2), error); Just remove this first 3 lines of code from assembly.. but I am not MS employee :) I believe that the issue is that .ashx files are handled by the
SimpleHandlerFactory while .aspx files are handled by the PageHandlerFactory. As Rick indicated in his post, the SimpleHandlerFactory does not the redirect process that occurs with the transfer process because this is embedded within the Page handler. It's not that the IHttpHandler is prohibited; it's because the simple handler doesn't understand what a page is necessarily. Now, what are you trying to attempt using a simple handler file in place of a page file? -- Christopher A. Reed "The oxen are slow, but the earth is patient." Show quote "Sam" <f**@tempuri.org> wrote in message news:OH$JUKiAGHA.2736@TK2MSFTNGP11.phx.gbl... > Rick Strahl [MVP] wrote: >> According to the documentation HttpServerUtilty.Execute/Transfer only >> works with pages... It simply may not work with handlers, because the >> redirect is occurring from within the Page Handler framework. If you want >> to redirect to a handler you need a physical redirect with >> Response.Redirect(). >> >> +++ Rick --- >> > > I need to save Context.Items and it's impossible to redirect. Anyway my > application need only Server.Execute. > > Quote from documentation: > > "Executes the handler for the specified virtual path in the context of the > current request." > > I trust, there is no reason to prohibit IHttpHanlder derived classes. > See Reflected code of HttpServerUtility.ExecuteInternal: > > ... > else if (!(handler is Page)) > { > error = new HttpException(0x194, string.Empty); > } > ... > handler.ProcessRequest(...) // BUT It's only for Page instances ((( > ... > object[] objArray2 = new object[] { handler.GetType().ToString() } ; > throw new > HttpException(SR.GetString("Error_executing_child_request_for_handler", > objArray2), error); > > > Just remove this first 3 lines of code from assembly.. but I am not MS > employee :) Christopher Reed wrote:
> I believe that the issue is that .ashx files are handled by the It's not depended on Handler factories or something else. There is not > SimpleHandlerFactory while .aspx files are handled by the > PageHandlerFactory. As Rick indicated in his post, the SimpleHandlerFactory > does not the redirect process that occurs with the transfer process because > this is embedded within the Page handler. It's not that the IHttpHandler is > prohibited; it's because the simple handler doesn't understand what a page > is necessarily. > > Now, what are you trying to attempt using a simple handler file in place of > a page file? necessary ashx or aspx or jpg. It's a bug, and this bug must be fixed. If method signature is: Server.Execute(IHttpHandler handler, ...) why I have an exception here? Instead it there must be Server.Execute(Page page,...) if handlers are prohibied. Is MS afraid that someone inherit ASP.NET :)? Please vote bugreport: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=c1c80d3f-4835-4be4-aa0a-e0dc82b43356 Rick Strahl [MVP] wrote:
> According to the documentation HttpServerUtilty.Execute/Transfer only works I need to save Context.Items and it's impossible to direct redirect. > with pages... It simply may not work with handlers, because the redirect is > occurring from within the Page Handler framework. If you want to redirect to > a handler you need a physical redirect with Response.Redirect(). > > +++ Rick --- > Anyway my application need only Server.Execute. Quote from documentation: "Executes the handler for the specified virtual path in the context of the current request." I trust, there is no reason to prohibit IHttpHanlder derived classes. See Reflected code of HttpServerUtility.ExecuteInternal: .... else if (!(handler is Page)) { error = new HttpException(0x194, string.Empty); } .... handler.ProcessRequest(...) // BUT It's only for Page instances ((( .... object[] objArray2 = new object[] { handler.GetType().ToString() } ; throw new HttpException(SR.GetString("Error_executing_child_request_for_handler", objArray2), error); Just remove this first 3 lines of code from assembly.. but I am not MS employee :) Next issue: Why I see the same behaviour with Server.Execute(IHttphandler handler, ...)? Here is IHttpHandler as method parameter.. and it don't work anyway. Why not System.Web.Page instead of IHttpHandler, if handlers are prohibited? True is buried within 3 lines above. Quote from docs for HttpServerUtility.Execute(IHttpHandler, TextWriter, Boolean): "Executes the current request by using a custom HTTP handler that implements the IHttpHandler interface. A TextWriter object captures output from the page and specifies whether to clear the QueryString and Form collections." Rick Strahl [MVP] wrote:
> According to the documentation HttpServerUtilty.Execute/Transfer only works I need to save Context.Items and it's impossible to direct redirect.> with pages... It simply may not work with handlers, because the redirect is > occurring from within the Page Handler framework. If you want to redirect to > a handler you need a physical redirect with Response.Redirect(). > > +++ Rick --- > Quote from documentation: "Executes the handler for the specified virtual path in the context of the current request." I trust, there is no reason to prohibit IHttpHanlder derived classes. See Reflected code of HttpServerUtility.ExecuteInternal: .... else if (!(handler is Page)) { error = new HttpException(0x194, string.Empty); } .... handler.ProcessRequest(...) // BUT It's only for Page instances ((( .... object[] objArray2 = new object[] { handler.GetType().ToString() } ; throw new HttpException(SR.GetString("Error_executing_child_request_for_handler", objArray2), error); Just remove this first 3 lines of code from assembly.. but I am not MS employee :) Next issue: Why I see the same behaviour with Server.Execute(IHttphandler handler, ...)? Here is IHttpHandler as method parameter.. and it don't work anyway. Why not System.Web.Page instead of IHttpHandler, if handlers are prohibited? True is buried within 3 lines above. Quote from docs for HttpServerUtility.Execute(IHttpHandler, TextWriter, Boolean): "Executes the current request by using a custom HTTP handler that implements the IHttpHandler interface. A TextWriter object captures output from the page and specifies whether to clear the QueryString and Form collections." |
|||||||||||||||||||||||