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. General Programming
  3. C#
  4. Page Navigation

Page Navigation

Scheduled Pinned Locked Moved C#
sysadminhelpquestion
4 Posts 3 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.
  • P Offline
    P Offline
    pravin_mun
    wrote on last edited by
    #1

    I have the following code after this execution i have to navigate to other Page can any one help me out.. Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Export.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); HtmlForm frm = new HtmlForm(); gv.Parent.Controls.Add(frm); frm.Attributes["runat"] = "server"; frm.Controls.Add(gv); frm.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); Response.Redirect()// Not working Server.Transfer()// Not working Please any one help me to navigate to other page here ?? Thanks in Advance.

    H L 2 Replies Last reply
    0
    • P pravin_mun

      I have the following code after this execution i have to navigate to other Page can any one help me out.. Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Export.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); HtmlForm frm = new HtmlForm(); gv.Parent.Controls.Add(frm); frm.Attributes["runat"] = "server"; frm.Controls.Add(gv); frm.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); Response.Redirect()// Not working Server.Transfer()// Not working Please any one help me to navigate to other page here ?? Thanks in Advance.

      H Offline
      H Offline
      Hum Dum
      wrote on last edited by
      #2

      you are terminating response at this line

      pravin_mun wrote:

      Response.End();

      comment out this line, Response.Redirect("URL") should work then. Regards

      P 1 Reply Last reply
      0
      • H Hum Dum

        you are terminating response at this line

        pravin_mun wrote:

        Response.End();

        comment out this line, Response.Redirect("URL") should work then. Regards

        P Offline
        P Offline
        pravin_mun
        wrote on last edited by
        #3

        No Luck..!! Tried with the same.. Getting this exception..!("Cannot redirect after HTTP headers have been sent.")

        1 Reply Last reply
        0
        • P pravin_mun

          I have the following code after this execution i have to navigate to other Page can any one help me out.. Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Export.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); HtmlForm frm = new HtmlForm(); gv.Parent.Controls.Add(frm); frm.Attributes["runat"] = "server"; frm.Controls.Add(gv); frm.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); Response.Redirect()// Not working Server.Transfer()// Not working Please any one help me to navigate to other page here ?? Thanks in Advance.

          L Offline
          L Offline
          Lukasz Nowakowski
          wrote on last edited by
          #4

          First of all, I don't understand why you want to redirect after sending anything to browser. Didn't check that in VS, but believe the problem is that you are modifying response, and then doing Response.Redirect. Try removing lines: Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Export.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Write(pdfDoc); Response.End(); And check if Response.Redirect works.

          Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

          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