title: Server displays an old version of an application created with VB.NET
body: <p>I have created an application in VB.NET that is responsible for creating a PDF using iTextSharp. It is hosted on a Windows Web Server with IIS. But sometimes it happens that the version delivered by the server is an old one, it does not show the latest changes made to the structure of the PDF. To solve it, I must upload the version that I have on my PC back to the server. Although I have not made any changes to the source code and it is exactly the same as the one on the server. Every time I invoke the .aspx file I do it with a random value parameter to try to avoid the cache, but apparently it is not the solution. I also have the following statement in the code: Response.Cache.SetCacheability (HttpCacheability.NoCache) Thank you very much for any help you can give me.<br />
  Here is how I create PDF: I use a function to create PDF and return it into a MemoryStream :</p>
  <pre><code>
  SendOutPDF(CreatePDF(&quot;Title&quot;, nro), nro)  
   
  Public Function CreatePDF(ByVal Titulo As String, ByVal Numero As Integer) As System.IO.MemoryStream  
      Dim PDFData As MemoryStream = New MemoryStream  
      ... 
      Dim pdfDoc As iTextSharp.text.Document  
      ...  
      Dim pdfWrite As PdfWriter = 
      iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, PDFData)  
      ... 
      Return PDFData  
  End Function  
  Protected Sub SendOutPDF(ByVal PDFData As System.IO.MemoryStream, ByVal num As Integer)  
      Response.Clear()  
      Response.ClearContent()  
      Response.ClearHeaders()  
      Response.ContentType = &quot;application/pdf&quot;  
      Response.Charset = String.Empty  
      Response.AddHeader(&quot;content-disposition&quot;, &quot;attachment;filename=&quot; &amp; num &amp; &quot;.pdf&quot;)  
      Response.Cache.SetCacheability(HttpCacheability.NoCache)  
      Response.OutputStream.Write(PDFData.GetBuffer, 0, PDFData.GetBuffer.Length)  
      Response.OutputStream.Flush()  
      Response.OutputStream.Close()  
      Response.End()  
  End Sub
  </code></pre>