[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.AddHeader "content-disposition","attachment; filename=" & sFilePath
' Create your header information
Response.ContentType = "application/x-msexcel"
' Create and configure your object
Set oFStream = Server.CreateObject("ADODB.Stream")
oFStream.Open
oFStream.Type = 1
oFStream.LoadFromFile(sFilePath)
' Stream it to the client
Response.BinaryWrite 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.Redirect 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 9718
"> 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.Redirect 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*@yadayadayada.com> wrote in message
news:eY**************@TK2MSFTNGP10.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*@yadayadayada.com> wrote in message news:eY**************@TK2MSFTNGP10.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*@yadayadayada.com> wrote in message
news:ej**************@TK2MSFTNGP11.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.AddHeader "content-disposition","attachment; filename=" & sFilePath
' Create your header information Response.ContentType = "application/x-msexcel"
' Create and configure your object Set oFStream = Server.CreateObject("ADODB.Stream") oFStream.Open oFStream.Type = 1 oFStream.LoadFromFile(sFilePath)
' Stream it to the client Response.BinaryWrite 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.contenttype and the response.addheader 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*******@newsgroup.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.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.AddHeader "content-disposition","attachment; filename=" & sFilePath
' Create your header information Response.ContentType = "application/x-msexcel"
' Create and configure your object Set oFStream = Server.CreateObject("ADODB.Stream") oFStream.Open oFStream.Type = 1 oFStream.LoadFromFile(sFilePath)
' Stream it to the client Response.BinaryWrite 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.Redirect 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...
|
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...
|
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...
|
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...
|
by: shyam |
last post by:
Hi All
I had raised a simillar query in an earlier post
...
|
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...
|
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...
|
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....
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |