I have been writing DNN modules for a long time and this is the first time I have had to give up.
I have a byte array that is a PDF file.
In the Render event of my control I write this array like follows:
Response.ContentType = "application/pdf"
Response.BinaryWrite(ReportBytes)
Response.Flush()
If the control is on a page that allows unauthenticated users and they are not logged in all works as expected.
If the user loggs in then the page displays with nothing.
If I add
Response.AppendHeader("content-disposition", "attachment; filename=fun")
All works fine for thoes not logged in and IE asks to open the file.
If they are logged in then I get the following error:
Cannot download Default.aspx from localhost. And the file dialog box looks like it is trying to download a file Default.aspx.
What is DNN doing to the Response object that would cause this?
I have tested the byte array and placed it on the server HD to make sure it is the same in each case and it is.
If I add:
Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
No longer will the PDF work if a user is logged off.