473,586 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Temporary user files under IIS - FAQ?

What's the usual way of handling temporary user files under ASP.NET running
on IIS? On a normal Windows client program, you'd probably store the
documents in the %TEMP% folder. However, aren't all users running under the
same ASPNET account so they're sharing the same TEMP folder? Also, you
really want them within the web-site folder so that normal HTML <IMG> tags
can be used.

We're using a temporary file to hold a user's photograph. This photograph is
stored in a SQL database as an IMAGE column. When the record is opened, we
need to create the temporary file with the same file name so that if the
user right-clicks, the default file name is correct, i.e. the original.

At the moment, we've created a User folder in the web site and build a
unique path using the session ID like this:

c:\inetpub\wwwr oot\ourwebsite\ users\378738273 87283\porky.jpg

Where 37873827387283 is the session ID. It works but doesn't feel quite
right :-) We also have to manually grant ASPNET write access to the Users
folder.

Any better ideas?

Thanks, Rob.
Nov 19 '05 #1
6 1670
I think your approach is wrong. You can write files directly to the
response stream ( and give them any name you want. read the file out of SQL
into an image ( bitmap) object and write that to the stream.
Nov 19 '05 #2
> I think your approach is wrong. You can write files directly to the
response stream ( and give them any name you want. read the file out of SQL into an image ( bitmap) object and write that to the stream.


Never used response streams but understand that you're suggesting. This
isn't a full screen image - it's a page containing information about a
person with an image control on the page. If you were mocking it up, you'd
have something like:

<asp:Image
id="Image1"
style="Z-INDEX: 100; LEFT: 704px; POSITION: absolute; TOP: 152px"
runat="server"
ImageUrl="Porky .jpg"
BorderStyle="So lid"
BorderWidth="1p x"
BorderColor="#7 F9DB9" Height="234px"
Width="234px">
</asp:Image>

The advantage of using a <IMG> tag (which is I assume what asp:Image ends up
as) is that if the user right-clicks, then can save-as using the original
file name.

I can't see how you can repeat this functionality using a response stream
which I think is basically an "on-the-fly" HTTP response sent back to the
browser. It's not stored anywhere except within the browser to render the
current page. It can't be linked to via a IMG SRC tag.

Cheers, Rob.
Nov 19 '05 #3
I'm thinking on my feet here but I'm sure you can write your file into the
midle of the html.

If you call a function from the HTML e.g.
<HTML>
<BODY>
<TABLE><TR><T D>
<% =MyFunction() %>
</TD></TR></TABLE>
</BODY>
</HTML>
then in the code behind

public void MyFunction()
{
Response.Write( "<IMG") ....
}
Nov 19 '05 #4
Rob Nicholson wrote:
I think your approach is wrong. You can write files directly to the
response stream ( and give them any name you want. read the file
out of SQL into an image ( bitmap) object and write that to the
stream.


Never used response streams but understand that you're suggesting.
This isn't a full screen image - it's a page containing information
about a person with an image control on the page. If you were mocking
it up, you'd have something like:

<asp:Image
id="Image1"
style="Z-INDEX: 100; LEFT: 704px; POSITION: absolute; TOP: 152px"
runat="server"
ImageUrl="Porky .jpg"
BorderStyle="So lid"
BorderWidth="1p x"
BorderColor="#7 F9DB9" Height="234px"
Width="234px">
</asp:Image>

The advantage of using a <IMG> tag (which is I assume what asp:Image
ends up as) is that if the user right-clicks, then can save-as using
the original file name.

I can't see how you can repeat this functionality using a response
stream which I think is basically an "on-the-fly" HTTP response sent
back to the browser. It's not stored anywhere except within the
browser to render the current page. It can't be linked to via a IMG
SRC tag.

Cheers, Rob.


An html-page with one image gives two requests to the browser: html-file
and image. (so you can't send the image along with the page)

Write the img-tag with an "src" pointing to some "getImage.a spx" (with appropriate
arguments to get the correct image).
In that getImage.aspx you read the image from the database and write it
(with Response.Binary Write) to the output (by the way: make sure the "aspx"
part contains no html code!).
But just before you do that, add some http headers:
Response.Append Header("Content-Disposition", "inline; filename=myfile .jpg");
Response.Conten tType = "image/jpg";

When the user wants to save the image, he doesn't get "getImage.aspx" , but
"myfile.jpg " as default filename. (of course: change that name to what you want)

No need for temporary files!

One thing you could change: when you retrieve the data for the page (including
the image), store that in Session. Then getImage.aspx doesn't need parameters,
it can just read the stored image.
Hans Kesting

Nov 19 '05 #5
Thanks for all your informative inputs.

Hi Rob,

As other members as mentioned, the <img src=... /> infact cause an
additional request to server to request the image. Generally this is a
static image file on the server. However, when the images we want to
display is to be retrieved from database, using static images files will be
abit hard since it need IO operations in our web application. Also,
creating those temporary files will need constant cleanup task , otherwise
there'll cause duplicated unuse files in the temp folder.

So in addition to your current solution, I think we can consider using a
HttpHandler to dynamically retrieve image and writeout as Image response
stream so that our <img src=../> tag can reference it. For example, our
aspx page which display image will become something like:

....
<img src="imagehandl er.axd?param1=x xx&param2=xxx" />

Here is a good tech article discussing building such an httphandler:

#Using ASP.NET HTTP Handlers to create a photo album
http://www.microsoft.com/belux/nl/ms...et/httphandler.
mspx

Hope also helps. 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 #6
Hi Rob,

Any further progress on this? Have you chosen a certain means for exposing
your image streams from db? Anyway, if there are still anything we can
help, please feel free to let us know. Thanks,

Regards,

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 #7

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

Similar topics

6
1842
by: Codemonkey | last post by:
Hi, I have a few questions about best practices when it comes to the management of temporary files. Any thoughts anyone can give would be much appreciated. Basically, I'm writing a document storage app - a Windows service acts as the file sotrage server and remote windows forms clients send files to the server to be stored. The temporary...
1
1554
by: Frank Lopez | last post by:
In .NET and C#, is there anyway to create a hook for a specific directory or file where my C# .NET software can monitor which static web files are requested by the browser? What I am doing is writing temporary files to a specific directory for a specific user, and then when the user has requested each file in that directory, I want to...
2
3135
by: Kiko + | last post by:
Hi, I've been getting this error: Server Error in '/applicationname' Application. ---------------------------------------------------------------------------- ---- Failed to create temporary files directory
12
5088
by: Chad Crowder | last post by:
Hi all, I hope someone can give me a hand, because I'm out of ideas. I keep getting this message: Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\projects_cig\e4e3b3da\3c20ac69" is denied. The error goes on to say that the ASP.NET is not authorized...
7
2299
by: Norton | last post by:
Hi all, I would like to know if there is any method in asp or asp.net to direct the browser to download a file into the Temporary Internet Files directory so that i can make use of vb script to do the further process ie. tells IE to download my desired Word File into the Temporary Internet Files and call an office com object to open it
4
2339
by: Nicolás Castagnet | last post by:
Hi, I write this post because I notice a strange behavior related with "Temporary Internet Files" and maybe some of you can help me to understand it. I am working in a web application with ASP.NET. Recently, I group of user have problems with it because the values of the sessions were not stored correctly (the application save the...
1
4287
by: Manish | last post by:
Hi all, Can any one plz suggest me how i can delete my temporary internet files within my Asp.net page. I am using C# as the code behind lang. Indeed, i have flash inserted on my .net page, which in turn gets its values from the xml file which gets generated at the run time according to the selection of the user in a DropDownList. I want...
4
28944
by: Anbu | last post by:
Hi all, I have developed an application in VS .NET 2003 (framework 1.1) on a XP platform. It is working fine in that PC. Now, I setup new PC with same configuration for another develper. Whenever I execute the application it gives, Unauthorize Exception error and it's not execting the application property. The Error message is as...
5
3415
by: rogersw8n | last post by:
Some how, some way the account that creates folders under Temporary Internet files has been changed to a domain account for VS 2003 and VS 2005. I recently installed VS 2005. All seemed to be ok afterwards. I did no development for a couple of weeks, came back and I kept receiving Access Denied to Microsoft.Net\Temporary Internet Files\......
0
2937
by: wolfsbane | last post by:
Alright, here it is I am trying to write a win32 app in VB 2005 to clean up user's profiles. everything works correctly except for the Delete("directory", True) statement. I get a System.IO.DirectoryNotFoundException: Could not find a part of the path. Then it gives me a random file name from the UserProfile\Local Settings\Temporary Internet...
0
7912
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, 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...
0
8202
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
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...
0
8216
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 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...
0
6614
agi2029
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...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.