[Apologies for previous half-post: I regularly mistype some kind of key
combo that submits the post]
I have a page on our intranet that is supposed to stream an Excel sheet to
the user. I'm using pretty standard code:
sFilePath = sFileDir & sFilename
Response.AddHea der "content-disposition","a ttachment; filename=" & sFilePath
' Create your header information
Response.Conten tType = "applicatio n/x-msexcel"
' Create and configure your object
Set oFStream = Server.CreateOb ject("ADODB.Str eam")
oFStream.Open
oFStream.Type = 1
oFStream.LoadFr omFile(sFilePat h)
' Stream it to the client
Response.Binary Write oFStream.Read
' Cleanup
oFStream.Close
Set oFStream = Nothing
' force the end
Response.End
This works fine on the main server, but not on my development machine (XP
Pro x64). This has all worded in the past, but this is a new machine, and I
can't get it to work since I've moved across. I'm getting a 'File could not
be opened' error message. In the past, I've had this error when I wasn't
pointing at the right place or where the permissions were not configured
correctly.
Currently the IUSR user has R/W access to the whole folder where the XLS
file is (It's actually in the same folder as the ASP page at them moment).
I've also checked that the filename and path are correct in a number of
ways, including using FSO.FileExists( ) and it it correct.
But I'm still getting this message... Any ideas?
I also stumbled across a suggestion to simple Response.Redire ct to the
file - ironically, this 1-line solution works perfectly. I assume there must
be a caveat or downside to using this technique - otherwise everybody would
be using it. Can anyone sged some light on this?
Cheers
Chris 7 9765
"> Currently the IUSR user has R/W access to the whole folder where the XLS file is (It's actually in the same folder as the ASP page at them moment). I've also checked that the filename and path are correct in a number of ways, including using FSO.FileExists( ) and it it correct.
But I'm still getting this message... Any ideas?
Have you checked the security of the file itself? It may not be inheriting
from the folder?
I also stumbled across a suggestion to simple Response.Redire ct to the file - ironically, this 1-line solution works perfectly. I assume there
must be a caveat or downside to using this technique - otherwise everybody
would be using it. Can anyone sged some light on this?
The caveat is that the file needs to be available in the virtual folder
space of the application which means a savvy client can navigate directly to
it. This may not be problem for you. OTH you might want your ASP to
perform some authorisation first.
Anthony.
"Anthony Jones" <An*@yadayadaya da.com> wrote in message
news:eY******** ******@TK2MSFTN GP10.phx.gbl...
Have you checked the security of the file itself? It may not be inheriting from the folder?
The file *has* inherited the correct permissions from the parent folder. The caveat is that the file needs to be available in the virtual folder space of the application which means a savvy client can navigate directly to it. This may not be problem for you. OTH you might want your ASP to perform some authorisation first.
This is not something I'd worry about in this specific instance, but it
would be an issue in some cases, so it's good to be aware of it.
I'd still much prefer to use the streaming method...
Cheers
Chris
Normally it is not the IUSR account that will need permission if your asp
page is streaming data to the client. Typically the security account needing
permission to the file/folder will be either the 'Network Service' acocunt or
'ASP.NET' account. Try giving access to one or both of those accounts.
"CJM" wrote: "Anthony Jones" <An*@yadayadaya da.com> wrote in message news:eY******** ******@TK2MSFTN GP10.phx.gbl...
Have you checked the security of the file itself? It may not be inheriting from the folder?
The file *has* inherited the correct permissions from the parent folder.
The caveat is that the file needs to be available in the virtual folder space of the application which means a savvy client can navigate directly to it. This may not be problem for you. OTH you might want your ASP to perform some authorisation first.
This is not something I'd worry about in this specific instance, but it would be an issue in some cases, so it's good to be aware of it.
I'd still much prefer to use the streaming method...
Cheers
Chris I'd still much prefer to use the streaming method...
It's slower and uses way more memory but it your files are small enough
shouldn't be too much of a problem.
Anthony.
"Anthony Jones" <An*@yadayadaya da.com> wrote in message
news:ej******** ******@TK2MSFTN GP11.phx.gbl... I'd still much prefer to use the streaming method...
It's slower and uses way more memory but it your files are small enough shouldn't be too much of a problem.
But for internet sites, or secure intranet pages, we can have the streamed
content in an area inaccessible to the user... In this case, it's not an
issue, but there are cases that I can think of that would matter...
CJM
CJM wrote: [Apologies for previous half-post: I regularly mistype some kind of key combo that submits the post]
I have a page on our intranet that is supposed to stream an Excel sheet to the user. I'm using pretty standard code:
sFilePath = sFileDir & sFilename
Response.AddHea der "content-disposition","a ttachment; filename=" & sFilePath
' Create your header information Response.Conten tType = "applicatio n/x-msexcel"
' Create and configure your object Set oFStream = Server.CreateOb ject("ADODB.Str eam") oFStream.Open oFStream.Type = 1 oFStream.LoadFr omFile(sFilePat h)
' Stream it to the client Response.Binary Write oFStream.Read
' Cleanup oFStream.Close Set oFStream = Nothing
' force the end Response.End
This works fine on the main server, but not on my development machine (XP Pro x64). This has all worded in the past, but this is a new machine, and I can't get it to work since I've moved across. I'm getting a 'File could not be opened' error message. In the past, I've had this error when I wasn't pointing at the right place or where the permissions were not configured correctly.
Comment out the response.conten ttype and the response.addhea der lines,
and you will see your ASP error.
If your ASP is generating errors, it's that message that Excel is
trying to open as an excel file, hence the "file could not be opened"
message.
"CJM" <cj*******@news group.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. [Apologies for previous half-post: I regularly mistype some kind of key combo that submits the post]
I have a page on our intranet that is supposed to stream an Excel sheet to the user. I'm using pretty standard code:
sFilePath = sFileDir & sFilename
Response.AddHea der "content-disposition","a ttachment; filename=" & sFilePath
' Create your header information Response.Conten tType = "applicatio n/x-msexcel"
' Create and configure your object Set oFStream = Server.CreateOb ject("ADODB.Str eam") oFStream.Open oFStream.Type = 1 oFStream.LoadFr omFile(sFilePat h)
' Stream it to the client Response.Binary Write oFStream.Read
' Cleanup oFStream.Close Set oFStream = Nothing
' force the end Response.End
This works fine on the main server, but not on my development machine (XP Pro x64). This has all worded in the past, but this is a new machine, and I can't get it to work since I've moved across. I'm getting a 'File could not be opened' error message. In the past, I've had this error when I wasn't pointing at the right place or where the permissions were not configured correctly.
Currently the IUSR user has R/W access to the whole folder where the XLS file is (It's actually in the same folder as the ASP page at them moment). I've also checked that the filename and path are correct in a number of ways, including using FSO.FileExists( ) and it it correct.
But I'm still getting this message... Any ideas?
Is the virtual server or directory set for immediate expiry on your dev
machine? If so that message may be generated by the browser -- one way to
be sure is to set a custom error handler for error 500;100. Another would
be to disable errors in your ASP script.
Isolate the source of the error and go from there. If it's from the client,
it's likely being broken by immediate expiry.
-Mark
I also stumbled across a suggestion to simple Response.Redire ct to the file - ironically, this 1-line solution works perfectly. I assume there must be a caveat or downside to using this technique - otherwise everybody would be using it. Can anyone sged some light on this?
Cheers
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: REM |
last post by:
I have some problems. It's dilemma between BLOB, BFILE and takes care of
file on file system. What it's advantage??
I import some PDF document in BLOB filed in my database. It's about 1000
documents on day.
My first question is: if I have a PDF on file system about 100 kb and if I
import this in BLOB field in database. How much it's take more recourse.
|
by: Daniel Cardoso |
last post by:
I don't know what else to try - In my asp.net app, when the file name has
Windows-1252 characters (like ã and ç), these characters appear, each one,
as two strange characters in the file name label in Internet Explorer File
Download Dialog that is shown when I click a link to download the file. The
file content is being generated on-the-fly using asp.net and the filename is
being passed using a call to Response.AddHeader with the strings...
|
by: **Developer** |
last post by:
When I get the image from the file the file remains locked so the Delete
fails with a "used by another process"
So I tried using a clone and disposing the obtained image.
But that didn't fix the problem.
Can you help?
|
by: chinthamani |
last post by:
Hai
I want to open a file and read when the same file is already opened for
writing. I need to do the reading process simultaniously when the file is
being writen.
Regards.
S.Vinodh Noel
Software Engineer
(Bells Softech Limited)
Bangalore.
|
by: shyam |
last post by:
Hi All
I had raised a simillar query in an earlier post
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/f371af248d90ead6/1d054627402539e1?lnk=gst&q=ofstream+write+failure&rnum=1#1d054627402539e1
Basically
I have a file which is opened through ofstream for writing.
Now I want to check if the file has been deleted or not, while being in
| |
by: Martin Arvidsson, Visual Systems AB |
last post by:
Hi!
I want to create an event that is fiered when a file is accessed (Opened).
What i want to do is monitor a directory and subdirectory if files are
opened.
I have tried to use the FileSystemWatcher. But it didn't work as i expected.
I cant get it to fire an event when a file is accessed.
|
by: vunet.us |
last post by:
What is the workaround of passign a parameter to any included asp
file:
<!-- #Include File="file.asp" -->
This obviously does not work:
<!-- #Include File="file.asp?id=123" -->
Thank you
|
by: weird0 |
last post by:
System.Data.SqlClient.SqlException: An attempt to attach an auto-
named database for file "Location" failed. A database with the same
name exists, or specified file cannot be opened, or it is located on
UNC share.
I am getting the above the exception while connecting to the db and i
have written a web-service...
i.e. a webmethod.
What do I do? Why am i getting this error ? How can i remove this
|
by: VijaySofist |
last post by:
Hi All!
I want to check whether a given text File is Already Opened or not. I am using Visual Basic 6.0 in the Windows XP OS.
I am using the following code. It works for .doc, .xls and .mdb. But its not working for .txt file type
Public Function IsFileOpen(FileName As String) As Boolean
On Error GoTo ErrHandler
Open FileName For Binary Access Read Lock Read As #1
|
by: raylopez99 |
last post by:
I have the latest version of Visual Studio 2008 Professional, which
allows you to create resource files (this is the .resx file, no?),
unlike the Express version, which does not.
I am trying to cut and paste code that MSDN recommends for playing a
simple wav file from inside an embedded file, like presumeably the
'resources' file .resx is. I want to embed the .wav file in a
'resource file' since I don't want the user storing the file on...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |