473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C# ASP.NET Browse for Folder from a Web page

I have an Oracle database that holds a Blob field containing a PDF
report. I've been researching into if its possible to implement a Brose
for folder functionality in a web page so to allow a user to specify a
folder to download the PDF to. The only way I can think of doing this at
the moment is to first download the report to the Webserver and then
have a link on the web page to the location of the downloaded report and
then the user would access like a standard link to a file. What I would
really like to do is to allow the user to select a folder location and
then download directly to that location rather than storing the output
temporarily on the web server. Is it possible to implement browse folder
functionality from a web page?
I know its possible using a Windows Form application.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
5 20583
Joe,

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]
- mv*@spam.guard.caspershouse.com

"Joe Bloggs" <bo********@netscape.net> wrote in message
news:eV**************@TK2MSFTNGP14.phx.gbl...
I have an Oracle database that holds a Blob field containing a PDF
report. I've been researching into if its possible to implement a Brose
for folder functionality in a web page so to allow a user to specify a
folder to download the PDF to. The only way I can think of doing this at
the moment is to first download the report to the Webserver and then
have a link on the web page to the location of the downloaded report and
then the user would access like a standard link to a file. What I would
really like to do is to allow the user to select a folder location and
then download directly to that location rather than storing the output
temporarily on the web server. Is it possible to implement browse folder
functionality from a web page?
I know its possible using a Windows Form application.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
Hi Nicholas,
thank you very much for the reply. I will try and implement your
recommendation and let you know of progress.
Thank you
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
Hi Nicholas,
I tried your suggestion but I'm getting stuck where I write my .pdf to
the blob as a byte[] type and I'm unable to read directly as a byte[]
type when I retrieve from the warehouse. Where I am at now is I have my
link now to the APSX page and I'm passing the ID to identify the record
containing the blob see code below.

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(req uestid,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.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
Joe Bloggs wrote:
Hi Nicholas,
I tried your suggestion but I'm getting stuck where I write my .pdf to
the blob as a byte[] type and I'm unable to read directly as a byte[]
type when I retrieve from the warehouse. Where I am at now is I have
my link now to the APSX page and I'm passing the ID to identify the
record containing the blob see code below.
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(req uestid,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
Nov 16 '05 #5
Thanks - I was missing Response.BinaryWrite(data); It works now :-)
On the point of passing an id as a parameter being a security risk , is
there any best practice on how parameters can be passed securely. I am
going to implement an encryption/decryption algorithm between the
redirect and the directed to page.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mscir | last post by:
I just installed ASP after a couple of years of not using it, PWS Win 98 SE. A couple of things are throwing me, and I can't remember whether these worked in the past. One is I can't...
6
by: Glenn Owens | last post by:
As a "newbie" to Javascript I need some help with my latest problem... I have a number of image files that have been pre-selected by the user for downloading. I'd like to be able to have the user...
21
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what...
5
by: deko | last post by:
I'm using the below code to allow users to browse for and select a folder. After selecting a folder from the dialog, the full path is returned to a text box and saved. The next time the user...
5
by: Eric Twietmeyer | last post by:
Hi, Does anyone know why starting with VS.NET 2002 (and same with 2003) it is no longer possible to browse to a directory that has "ept" as part of the path? It worked fine in Vc 6.x. My...
4
by: Larry Brindise | last post by:
I have an asp.net application. I have used VStudio Web Deployment Project to create the MSI file. I copy the MSI file from my developer PC to my test server running Win2003Server Web Edition. I...
5
by: Dan | last post by:
I am working on a C# ASP.NET project where I need to allow the user to browse to a folder. The only way I see how to do this is use <input type=file>. But this makes the user select a file and...
5
by: Mike Moore | last post by:
I need to create something very similiar to the browse folder capability. This would allow me to support the following - A user would create a document on their server, then they would need to...
3
by: Highlander | last post by:
Hello all. Consider the following HTA: <HTML> <HEAD> <TITLE></TITLE></HEAD> <BODY> <SCRIPT LANGUAGE="VBScript"> Sub ButBrowse_onclick() '-- show browse window and Get file path:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.