Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Server.Execute fails in postback

Server.Execute fails in postback

Scheduled Pinned Locked Moved ASP.NET
helpsysadmin
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anish Gopi
    wrote on last edited by
    #1

    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!

    M 1 Reply Last reply
    0
    • A Anish Gopi

      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!

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • M minhpc_bk

        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.

        A Offline
        A Offline
        Anish Gopi
        wrote on last edited by
        #3

        Thanks for the suggetion i am confused that the error shown only in Postback . For the first time its a succesful Execution

        M 1 Reply Last reply
        0
        • A Anish Gopi

          Thanks for the suggetion i am confused that the error shown only in Postback . For the first time its a succesful Execution

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          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>

          A 1 Reply Last reply
          0
          • M minhpc_bk

            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>

            A Offline
            A Offline
            Anish Gopi
            wrote on last edited by
            #5

            Thanks it run succesfully

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups