Temporary ASP.NET Files Location?

Discussion in 'ASP .Net' started by localhost, Jun 1, 2004.

  1. localhost

    localhost Guest

    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.
     
    localhost, Jun 1, 2004
    #1
    1. Advertising

  2. 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.)
     
    Steven Cheng[MSFT], Jun 2, 2004
    #2
    1. Advertising

  3. 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
     
    Steven Cheng[MSFT], Jun 4, 2004
    #3
  4. localhost

    localhost Guest

    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.




    On Wed, 02 Jun 2004 02:25:38 GMT,
    (Steven Cheng[MSFT]) wrote:

    >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.)
    >
    >
    >
     
    localhost, Jun 7, 2004
    #4
  5. 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
     
    Steven Cheng[MSFT], Jun 9, 2004
    #5
  6. 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
     
    Steven Cheng[MSFT], Jun 10, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Natty Gur
    Replies:
    2
    Views:
    4,309
    Yan-Hong Huang[MSFT]
    Jul 3, 2003
  2. Replies:
    1
    Views:
    683
    bruce barker
    Feb 22, 2007
  3. Ralf Kaiser
    Replies:
    2
    Views:
    485
    Ralf Kaiser
    Mar 6, 2007
  4. Martin Erskine

    Help! - ASP.NET cannot 'Temporary ASP NET Files'

    Martin Erskine, Sep 17, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    133
    Martin Erskine
    Sep 17, 2003
  5. Allan Cammish

    Best location to install temporary files

    Allan Cammish, Dec 31, 2003, in forum: ASP General
    Replies:
    1
    Views:
    136
    Ray at
    Dec 31, 2003
Loading...

Share This Page