473,406 Members | 2,707 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,406 software developers and data experts.

Unable to open file

Dear Experts,

In my web application, I'm having a button to view an attachment. After I
retrieve the record from database (Ms. Access), I have a button to view the
attachment (if there is any). The button work fine when I run it at my local
machine. However, when I moved all the programs over to the server, I am
unable to view the attachment, although I have the file physically at the
server. The error message that I got is:

------------------------------------------------------------------------
Server Error in '/ITRS_Testing' Application.
--------------------------------------------------------------------------------

Operation is not allowed when the object is closed.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Operation is
not allowed when the object is closed.

Source Error:

Line 26:
Line 27: ' This should be the full path and filename to save the
file on the client....
Line 28: objStream.SaveToFile(strFilename, 2) ' adSaveCreateOverWrite
Line 29: objStream.Close()
Line 30: objStream = Nothing

Source File: D:\ITRS_Testing\ITRS\EnquiryResult.aspx Line: 28

Stack Trace:

[COMException (0x800a0e78): Operation is not allowed when the object is
closed.]

Microsoft.VisualBasic.CompilerServices.LateBinding .InternalLateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn) +776
Microsoft.VisualBasic.CompilerServices.NewLateBind ing.LateCall(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean
IgnoreReturn) +365640
ASP.itrs_enquiryresult_aspx.ViewDoc(Object Source, EventArgs E) in
D:\ITRS_Testing\ITRS\EnquiryResult.aspx:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument)
+107

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.42
----------------------------------------------------------------------------------

The code in my program is as follow:

Public Sub ViewDoc(ByVal Source As Object, ByVal E As EventArgs)
Dim strFilename As String
'================================================= ==============
' Example using ADODB Stream Object to load resource from server
' and deposit in specified directory on client, using client-side
' script
' Peter Bromberg
'================================================= ===============
' Don't need the TypeLib METADATA at the top if you specify the
constants by numeric value instead of by name

' Set up an ADO Stream ....
Dim objStream
objStream = CreateObject("ADODB.Stream")
objStream.Type = 1 ' adTypeBinary
' The following should be the absolute URL to the file on the
server.....
objStream.Open("URL=http://Teklang1/ITRS_Testing/ITRS/Attachments/"
& Trim(txtAttachment.Text))
'objStream.Open("//Teklang1/ITRS_Testing/ITRS/Attachments/" &
Trim(txtAttachment.Text))

Dim objFSO
objFSO = Server.CreateObject("Scripting.FileSystemObject")
strFilename = objFSO.getSpecialFolder(2).path & "\" &
Trim(txtAttachment.Text)

' This should be the full path and filename to save the file on the
client....
objStream.SaveToFile(strFilename, 2) ' adSaveCreateOverWrite
objStream.Close()
objStream = Nothing
' Now we'll "run" the file....
Dim AttachFile As System.IO.FileInfo = New
System.IO.FileInfo(strFilename)
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" &
AttachFile.Name)
Response.AddHeader("Content-Length", AttachFile.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(AttachFile.FullName)
Response.End()
End Sub
----------------------------------------------------------------------

Please advise where is the mistake that I have made. Many thanks in advance.

Feb 20 '06 #1
6 3513
Seok,

Mostly are this kind of problems that the ASPNET user has not the proper
rights.

Be very careful with giving the ASPNET or other general user rights, if you
do that wrong you are able to open your complete server for the outer world.

I hope this helps,

Cor
Feb 20 '06 #2
Cor,

Can I create the ASPNET user in the webserver which is also the domain
controller of my company. It is running on Window 2000 sp4. Which means can I
create the user in the Active Directory?

"Cor Ligthert [MVP]" wrote:
Seok,

Mostly are this kind of problems that the ASPNET user has not the proper
rights.

Be very careful with giving the ASPNET or other general user rights, if you
do that wrong you are able to open your complete server for the outer world.

I hope this helps,

Cor

Feb 21 '06 #3
Seok,

It should be already there ASPNET is his name.

Cor

"Seok Bee" <se*****@yahoo.com> schreef in bericht
news:2E**********************************@microsof t.com...
Cor,

Can I create the ASPNET user in the webserver which is also the domain
controller of my company. It is running on Window 2000 sp4. Which means
can I
create the user in the Active Directory?

"Cor Ligthert [MVP]" wrote:
Seok,

Mostly are this kind of problems that the ASPNET user has not the proper
rights.

Be very careful with giving the ASPNET or other general user rights, if
you
do that wrong you are able to open your complete server for the outer
world.

I hope this helps,

Cor

Feb 21 '06 #4
I've checked from the Active Directory and the user ASPNET is not there?
Does that mean I need to install certain thing?

"Cor Ligthert [MVP]" wrote:
Seok,

It should be already there ASPNET is his name.

Cor

"Seok Bee" <se*****@yahoo.com> schreef in bericht
news:2E**********************************@microsof t.com...
Cor,

Can I create the ASPNET user in the webserver which is also the domain
controller of my company. It is running on Window 2000 sp4. Which means
can I
create the user in the Active Directory?

"Cor Ligthert [MVP]" wrote:
Seok,

Mostly are this kind of problems that the ASPNET user has not the proper
rights.

Be very careful with giving the ASPNET or other general user rights, if
you
do that wrong you are able to open your complete server for the outer
world.

I hope this helps,

Cor


Feb 21 '06 #5
Seok,

Are you sure that IIS and the proper Net framework version are installed?

Cor

"Seok Bee" <se*****@yahoo.com> schreef in bericht
news:62**********************************@microsof t.com...
I've checked from the Active Directory and the user ASPNET is not there?
Does that mean I need to install certain thing?

"Cor Ligthert [MVP]" wrote:
Seok,

It should be already there ASPNET is his name.

Cor

"Seok Bee" <se*****@yahoo.com> schreef in bericht
news:2E**********************************@microsof t.com...
> Cor,
>
> Can I create the ASPNET user in the webserver which is also the domain
> controller of my company. It is running on Window 2000 sp4. Which means
> can I
> create the user in the Active Directory?
>
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Seok,
>>
>> Mostly are this kind of problems that the ASPNET user has not the
>> proper
>> rights.
>>
>> Be very careful with giving the ASPNET or other general user rights,
>> if
>> you
>> do that wrong you are able to open your complete server for the outer
>> world.
>>
>> I hope this helps,
>>
>> Cor
>>
>>
>>


Feb 21 '06 #6
Yea, this is our webserver.
..NET Framework 2.0 is being installed. Now I'm installing .NET Framework 1.1
and the service pack

"Cor Ligthert [MVP]" wrote:
Seok,

Are you sure that IIS and the proper Net framework version are installed?

Cor

"Seok Bee" <se*****@yahoo.com> schreef in bericht
news:62**********************************@microsof t.com...
I've checked from the Active Directory and the user ASPNET is not there?
Does that mean I need to install certain thing?

"Cor Ligthert [MVP]" wrote:
Seok,

It should be already there ASPNET is his name.

Cor

"Seok Bee" <se*****@yahoo.com> schreef in bericht
news:2E**********************************@microsof t.com...
> Cor,
>
> Can I create the ASPNET user in the webserver which is also the domain
> controller of my company. It is running on Window 2000 sp4. Which means
> can I
> create the user in the Active Directory?
>
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Seok,
>>
>> Mostly are this kind of problems that the ASPNET user has not the
>> proper
>> rights.
>>
>> Be very careful with giving the ASPNET or other general user rights,
>> if
>> you
>> do that wrong you are able to open your complete server for the outer
>> world.
>>
>> I hope this helps,
>>
>> Cor
>>
>>
>>


Feb 21 '06 #7

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

Similar topics

3
by: David N | last post by:
I got a solution that contains about 30 projects, three of which cannot be open. When I open the project, I always receive the error message "Unable to get the project file from the Web Server" ...
8
by: Rob | last post by:
I asked this question before but having had no response i'll try to simplify the description and hope someone can help this time. Basically my problem is that i'm getting the error "Unable to...
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
7
by: Jed | last post by:
I am trying to open web project in VS 2003 using the File Share method. VS is running on XP Pro (Host) and I am accessing the root web of an XP Pro install on Virtual PC (Server) running on the...
0
by: bazzer | last post by:
hey, i am using visual basic.net 2003 and have an ASP.NET webform application thats accessing a microsoft access 2003 database. i kept getting the following error when i tried to run it: ERROR ...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
2
by: Sagar | last post by:
Hi Iam unable to open my ASP.Net web project HRMS.vbproj suddenly in VS.Net 2003 I am getthing this error. Unable to open Web project '/'. The file path 'D:\company\ASP\Web' does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
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...
0
isladogs
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...

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.