Temporary ASP.NET Files Location?

L

localhost

I want to determine within my code-behind only the location of the
current tem directory for ym ASP.NET files. For example, the latest
web app build on my system shows:

"c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\testapp\97e6075d\ca93f565\assembly\dl2\d5f616ee\9e1410d4_0348c401"

I know it is dynamic, but I want to determine what the current
directory is in-code.

Thanks.
 
S

Steven Cheng[MSFT]

Hi Localhost,

From your description, you're wanting to get the location of the ASP.NET's
Temporary folder for the web application, yes?

Based on my research, by default when the asp.net been installed on the
machine, it is set to a default position in the system dir, such as
F:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\{Applicaiton Name}

And this path can be override by ourself in the machine.config or
web.config file in the <compilation> element which contains the
"tempDirectory" attribute, you can view the following reference in MSDN on
this.

#<compilation> Element
http://msdn.microsoft.com/library/en-us/cpgenref/html/gngrfcompilationsectio
n.asp?frame=true

But be careful that if we manually specify another path for this, we'd have
to ensure the asp.net worker process account has the sufficient permissions
to it. Otherwise, there'll occur many unexpected security issues.

Also, I haven't found any buildin interfaces for retrieving the temporary
folder path, I think this is apparent to the developer users. Also since it
is the internal mechanism of the ASP.NET and can't be guarantee whether
this will be changed in the later version, we're not recommended to make
use of this feature. 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.)
 
S

Steven Cheng[MSFT]

Hi Localhost,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. 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.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
L

localhost

I want to determine, at run-time within my application code, what
directory is being used by the current ASP.NET application.

I do not want to touch machine.config to make any changes to the
directory.

I do not want to hardcode F:\WINDOWS\.... directory in my code.

I understand that the directory can change in a later version of .NET
- that is why I want to dynamically detect where it is for the
currently running application.

If I use Windows Explorer to manually set the NTFS ACL to "Everyone -
Read" for the Temporary ASP.NET files directory, and then start a web
app, I will get an access denied message type - and the message will
show the exact filesystem directory. This example tells me that the
ASP.NET instance knows where it is running. Since ASP.NET knows this
location, there must be some way for me as a developer to determine it
dynamically. Maybe a Reflection class will be helpful?

In addtion, the exact path is not
:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\{Applicaiton Name}" , it is actually
":\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\{Applicaiton Name}\{RandomAppKey}"



Could you please re-examine this issue?

Thanks.
 
S

Steven Cheng[MSFT]

Hi Localhost,

Thanks for your followup. Regarding on this issue, I'll consult some
further experts to see whether there is any workaround to get the temp dir
info. I'll update you as soon as I got any further info. 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.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Steven Cheng[MSFT]

Hi Localhost,

After further researching, I think curently we can only use the Reflection
API to get the current executing assembly's path such as

using System.Reflection;
......................

Response.Write("<br>" + Assembly.GetExecutingAssembly().Location);

It'll give the dynamic assembly's full path , like:
f:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net
files\formauthapp\5ea2877c\82b56ee2\assembly\dl2\6333ec5f\60f0576f_994ec401\
formauthapp.dll

Thus, we can make use of this path to get the path info we want. 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.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top