468,290 Members | 1,895 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,290 developers. It's quick & easy.

Server.Execute & HttpHandler

Sam
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(IHttp Handler 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
Dec 16 '05 #1
6 4357
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 ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com
www.west-wind.com/weblog

"Sam" <fo*@tempuri.org> wrote in message
news:uQ**************@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(IHttp Handler 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

Dec 16 '05 #2
Sam
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 :)
Dec 16 '05 #3
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."

"Sam" <fo*@tempuri.org> wrote in message
news:OH**************@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 :)

Dec 16 '05 #4
Sam
Christopher Reed wrote:
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?


It's not depended on Handler factories or something else. There is not
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/produc...a-e0dc82b43356
Dec 17 '05 #5
Sam
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 direct 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 :)

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."
Dec 17 '05 #6
Sam
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 direct redirect.

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."
Dec 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Srini | last post: by
8 posts views Thread by bryan | last post: by
1 post views Thread by Lopamudra | last post: by
1 post views Thread by =?Utf-8?B?Y2hhaXJtYW4=?= | last post: by
2 posts views Thread by Fernando Rodriguez | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.