473,385 Members | 1,769 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,385 software developers and data experts.

Downloading/opening file in client application window

The following code added to Page_Load works a treat:

Response.ContentType = "application/zip"
Response.AppendHeader("Content-Disposition", "attachment;
filename=DesktopChange.pdf")
Response.WriteFile("C:\Inetpub\wwwroot\Download\De sktopChange.pdf")
Response.Flush()

But *only* if the document exists in the web site or is accessible by the
ASPNET account. However, it fails if the document is stored on the network,
e.g. s:\temp\desktopchange.pdf. This isn't surprising as the ASPNET can't
access s:\Temp.

One workaround we've though of is using the upload file functionality to
upload from the client to the server into a temporary file and then serve up
this temporary file.

But this requires an upload and a download which is waste.

Anyone got any ideas how to solve this?

Cheers, Rob.
Nov 19 '05 #1
3 1719
> One workaround we've though of is using the upload file functionality to
upload from the client to the server into a temporary file and then serve up this temporary file.


Ahh, we've realised the flaw in this paragraph as it goes like this:

BEGIN
Server knows the name of a file stored either on the client or on a network
share accessible from the client
Automatically upload it to the server [A]
Use Response.AppendHeader("Content-Disposition", "attachment; filename=XYZ")
to fire it back at the browser
END

The flaw is step [A] which is in effect giving the server the ability to
upload *any* file at will. Dangerous...

A workaround is to display a popup window which is in effect a <input
type=file> form which allows the uses to click "Upload" to upload the file
to the server so the server can then throw it back via
Response.AppendHeader.

All very clumsy! This is why I don't like webapps :-)

Rob.
Nov 19 '05 #2
Hi,
Assuming that you are running on Windows2003, in order that aps.net to
access the netowork resources, service should be running under network
service acount. also the folder being accessed should be configured to allow
the netowrk service account.
Regards
Sambathraj
"Rob Nicholson" <in******@community.nospam> wrote in message
news:eM**************@TK2MSFTNGP15.phx.gbl...
The following code added to Page_Load works a treat:

Response.ContentType = "application/zip"
Response.AppendHeader("Content-Disposition", "attachment;
filename=DesktopChange.pdf")
Response.WriteFile("C:\Inetpub\wwwroot\Download\De sktopChange.pdf")
Response.Flush()

But *only* if the document exists in the web site or is accessible by the
ASPNET account. However, it fails if the document is stored on the
network,
e.g. s:\temp\desktopchange.pdf. This isn't surprising as the ASPNET can't
access s:\Temp.

One workaround we've though of is using the upload file functionality to
upload from the client to the server into a temporary file and then serve
up
this temporary file.

But this requires an upload and a download which is waste.

Anyone got any ideas how to solve this?

Cheers, Rob.

Nov 19 '05 #3
Thanks for your posting Rob,

As for web application, the clientside ability is very restricted and web
application can't access most of the clientside resource. For example, we
can't alert or retreive any file on the clientside's local disk.(If not
using ActiveX control or other strong-typed code) The only means to
retrieve file stream from clientside is using the <input type="file" ../>
as you mentioned, this will need the client user to select file
interactively. So I don't think there will exit any security concern when
uploading file from client to server.

In addition, as for your scenario, you'd like to upload file from client to
server and write out the file to client again as attachment? I'm not sure
what's your application's detail logic, would you provide some further info
so that we may have a look to see whether there're any other potential
approachs?

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 19 '05 #4

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

Similar topics

3
by: ASP Spam Fighter | last post by:
Curt_C Wrote: > open the request in a new window That would work fine for me, but I'm writing this script for people who believe that we must assume total and utter user stupidity. Since this...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
5
by: John Morgan | last post by:
I am using the following link to download a file of about 50k <a target= "_blank" href="http://www.bsecs.org.uk/ExecDocs/documentStore/elfridaWord.doc">open file</a> If I save the file to...
4
by: Jeremy Ames | last post by:
Is there a way, without using javascript, to open a new browser window at set the window attributes? I want to set the size, turn off the status bar, address bar, menu bar, and etc. Can someone...
3
by: bfmcfarlane | last post by:
I have an appication that allows users to upload and download files. This application is only accessed when a user clicks on an "Upload / Download" link from within our main application. A new...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
1
by: apondu | last post by:
Hi, I am new to web services and i am facing a problem. I am interested in downloading some file from internet and use it for furthur processing For eg. i have a file at a the following URL and...
1
by: captainwin | last post by:
Here's the problem: - Website is ASP.NET 1.0 - Server is Windows Server 2003 - Browser is IE 6/7 - Client requests a mail merged MS Word 97 - 2003 document on the website, and the document gets...
0
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.