Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems generating then presenting file in ASP.NET site

Status
Not open for further replies.

LWComputingMVP

IS-IT--Management
Jul 3, 2005
870
US
One of my clients wants to generate a Word document and prompt the user to open or download it. They have the generation part working, but it always prompts for a username and password (domain user/password). I have tried setting permissions on the folder where the file is generated so that the IUSR account has full control - in trying to figure it out, I even gave EVERYONE full control at one point, but neither worked. Any suggestions?
 
Is there any reason to persist the file? If you can manage to intercept the Stream before it gets written to the file system (assuming this is happening in real time), then you can write the stream directly to the Response and avoid the file IO and subsequent cleanup.

Also, what sort of permissions are set on the file (not the folder)?

MCP, MCTS - .NET Framework 2.0 Web Applications
 
is the file on the same server? if not you may need to delegate rights from the IIS server to the remote server.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Is there any reason to persist the file?
None that I'm aware of - just that the developers were apparently uncertain of what else to do. For reference, the file is called "print.doc" and is created in a folder on the web server system itself (it's not on another server).
If you can manage to intercept the Stream before it gets written to the file system (assuming this is happening in real time), then you can write the stream directly to the Response and avoid the file IO and subsequent cleanup.
Sounds great! Any ideas/links on how to do this (I'll forward them on and maybe they can do it (I'm not an ASP.NET person, more of a Sys Admin).
Also, what sort of permissions are set on the file (not the folder)?
The file is dynamically created and assumes the permissions of the folder (I checked - they matched - but it still choked).
 
it could be the file was never closed/released.
1. open file writer
2. create file
3. [missing]
4. open file reader (error)

should be
1. open file writer
2. create file
3. close file writer
4. open file reader
5. display to user

there are many stream reader/writer objects. instead of using a filewriter which requires a file use a textwriter or binarywriter and write to a memorystream.

something this like [tt]BinaryWriter writer = new BinaryWriter(new MemoryStream());[/tt]
this will write the bites to memory instead of file. when you dispose of [tt]writer[/tt] you dispose of the memorystream. no additional cleanup required.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top