Server.Execute fails in postback
-
I try to work
Server.Execute
it works fine for the first Time . When i click a button(postback) ,Server.Execute
leads to an error "Error executing child request for content.htm"protected override void Render(HtmlTextWriter writer) { writer.Write(@" **pre** "); Server.Execute("content.htm",writer); base.Render (writer); writer.Write(@" **Post** "); }
Thanks for any help! -
I try to work
Server.Execute
it works fine for the first Time . When i click a button(postback) ,Server.Execute
leads to an error "Error executing child request for content.htm"protected override void Render(HtmlTextWriter writer) { writer.Write(@" **pre** "); Server.Execute("content.htm",writer); base.Render (writer); writer.Write(@" **Post** "); }
Thanks for any help!Hi there, The method
Server.Execute
works only when navigating to a Web Form page (.aspx). Using this method to execute a static file will result in an error like you are seeing now. So in this case as you may want to render the static html markup from an htm file to the output, so IMO you can simply provide a small snipet of code to read the content of the htm file and send it to the writer. -
Hi there, The method
Server.Execute
works only when navigating to a Web Form page (.aspx). Using this method to execute a static file will result in an error like you are seeing now. So in this case as you may want to render the static html markup from an htm file to the output, so IMO you can simply provide a small snipet of code to read the content of the htm file and send it to the writer.Thanks for the suggetion i am confused that the error shown only in Postback . For the first time its a succesful Execution
-
Thanks for the suggetion i am confused that the error shown only in Postback . For the first time its a succesful Execution
If you still want to use the
Server.Execute
method, then you can work around the error by declaring the handler for the static htm file at the ASP.NET engine in the web.config file. The setting looks something like:<system.web>
...
<httpHandlers>
<add verb="*"
path="*.htm"
type="System.Web.StaticFileHandler"/>
</httpHandlers>
...
</system.web> -
If you still want to use the
Server.Execute
method, then you can work around the error by declaring the handler for the static htm file at the ASP.NET engine in the web.config file. The setting looks something like:<system.web>
...
<httpHandlers>
<add verb="*"
path="*.htm"
type="System.Web.StaticFileHandler"/>
</httpHandlers>
...
</system.web>Thanks it run succesfully