Search code examples
asp.netasp-classicform-post

Classic ASP: posting with content of PDF file to a .NET page


So the problem is half the app is written in classic asp and half is in asp.net. There's a PDF file (in memory) that is generated by classic asp code that I need to share with the .NET half. I thought of saving the PDF to the FS or DB, which I am pretty sure most of you wouldn't recommend because it would need to go through a very slow process of saving to IO, and then I would need to manually clean up after -- unnecessarily creating more bottlenecks and failure points.

I thought of mimicking a post from the classic asp page to .NET by using Server.Transfer or Microsoft.XMLHTTP objects, but neither exactly fits the scenario as I really do want the URL on the client side to be pointing at the .NET aspx page. So is there a simple way to manufacture a POST from classic ASP to a .NET page with a PDF file embedded?

Thanks in advance for any comments or suggestions.


Solution

  • Somewhat of a hack, but...

    Create a form in classic ASP with a field that you populate with the data from the PDF file. The action of the form would be the ASP.NET page. Something like:

    <body onload="pdfsenderform.submit()">
        <form name="pdfsenderform" action="pdf.aspx" method="post">
           <input type="hidden" name="pdffiledata" value="<%...output your PDF data here...%>" />
       </form>
    </body>
    

    You might need to encode the binary PDF data prior to writing it to the form field (Base64 or something).