*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
It is possible to do it from an ASP.NET application, but I wouldn't
suggest it. You would have to embed a custom control, and then have it
installed on the client side, adjust the security, etc, etc.
However, I think that there is a much easier way. You can provide the
link to the document which would point to an ASPX page. This link would
have the ID embedded in the link, which you can then get (through the
QueryString property) and fetch the BLOB from the database. Once you have
that, you can pass the contents back to the user through the Write method on
the Response property.
You would have to add the content type and disposition, like this:
// Do this in Page_Load.
Response.Buffer = false;
Response.AddHeader("content-disposition", "attachment; filename=" +
<filename>);
Response.ContentType = "binary/octet";
Once you do this, the page will return the document in the blob, and the
user can choose to open it, or save it (and the Save File Dialog will be
presented to them).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Joe Bloggs" <books...@netscape.net> wrote in message
news:eVHYUttt...@TK2MSFTNGP14.phx.gbl...
string url = "UIReportDisplay.aspx?dbid=" + Request.QueryString["dbid"]
+ "&requestid=" + DataGrid1.DataKeys[DGridItem.ItemIndex].ToString();
Response.Redirect(url);
Then in the Page_Load of the page redirected to I have
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
byte[] data;
string dbid = Request.QueryString["dbid"];
string requestid = Request.QueryString["requestid"];
data = ReportUIClassLibrary.DBObjects.ShowOracleBlob1(requestid,dbid);
Response.Buffer = false;
Response.AddHeader("content-disposition", "attachment; filename=" +
data);
Response.ContentType = "binary/octet";
}
I get the Save or Open File dialog but the file name is System.Byte[] of
file type BYTE[] then even if I save as .pdf Acrobat Reader responds
that the file is corrupt. I write the PDF as a byte[] type to Oracle. I
tried converting the byte[] type to a file on the server and then
loading that into the blob, and I also tried using Response.Write(data)
and changing the content type to pdf but none have worked.
Any further assistance would be much appreciated, but thanks for your
help up to now anyway.
Note that exposing your primary keys as query parameters is unsecure,
because it allows users to access any PDF in your DB by simply incrementing
or decrementing "dbid" values.
> string url = "UIReportDisplay.aspx?dbid=" +
> Request.QueryString["dbid"] + "&requestid=" +
> DataGrid1.DataKeys[DGridItem.ItemIndex].ToString();
> Response.Redirect(url);
>
> Then in the Page_Load of the page redirected to I have
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> byte[] data;
> string dbid = Request.QueryString["dbid"];
> string requestid = Request.QueryString["requestid"];
> data = ReportUIClassLibrary.DBObjects.ShowOracleBlob1(requestid,dbid);
> Response.Buffer = false;
> Response.AddHeader("content-disposition", "attachment; filename=" +
> data);
> Response.ContentType = "binary/octet";
>
> }
You're not writing data to the response stream here. Is that done later or
just not there?
Cheers,
--
Joerg Jooss
www.joergjooss.de
ne...@joergjooss.de