Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Lossing Sessions and static varaibles becoming null [modified]

Lossing Sessions and static varaibles becoming null [modified]

Scheduled Pinned Locked Moved ASP.NET
helpquestionxml
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Satish Developer
    wrote on last edited by
    #1

    Hi, I have an web application. I am lossing sessions and static variables become null if i use the following code in my application.

    public string _xmlfilepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Code\\Culture.xml");
    public string _userfilepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Users");

    Even when i am using this code...the sessions are lost

    _userfilepath = Request.PhysicalApplicationPath + "Users\\";
    _xmlfilepath = Request.PhysicalApplicationPath + "App_Code\\Culture.xml";

    If i use this code then its working fine. Adding paths in web.config

    <add key="UserPath" value="F:\MyFolder\Users\" />
    <add key="CultureXML" value="F:\MyFolder\Admin\Culture.xml" />

    Later i am retirving those paths in application

    public string _userfilepath = ConfigurationManager.AppSettings["UserPath"];
    public string _xmlfilepath = ConfigurationManager.AppSettings["CultureXML"];

    But I dont know the drive names etc at client location to place my application. If i use the appdomain code then where ever this code placed the files will create in that directory itself. But the problem is i am loosing sessions and static variables becoming null. Due to this exceptions are arising. How can i overcome this issue?

    G. Satish

    P 1 Reply Last reply
    0
    • S Satish Developer

      Hi, I have an web application. I am lossing sessions and static variables become null if i use the following code in my application.

      public string _xmlfilepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Code\\Culture.xml");
      public string _userfilepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Users");

      Even when i am using this code...the sessions are lost

      _userfilepath = Request.PhysicalApplicationPath + "Users\\";
      _xmlfilepath = Request.PhysicalApplicationPath + "App_Code\\Culture.xml";

      If i use this code then its working fine. Adding paths in web.config

      <add key="UserPath" value="F:\MyFolder\Users\" />
      <add key="CultureXML" value="F:\MyFolder\Admin\Culture.xml" />

      Later i am retirving those paths in application

      public string _userfilepath = ConfigurationManager.AppSettings["UserPath"];
      public string _xmlfilepath = ConfigurationManager.AppSettings["CultureXML"];

      But I dont know the drive names etc at client location to place my application. If i use the appdomain code then where ever this code placed the files will create in that directory itself. But the problem is i am loosing sessions and static variables becoming null. Due to this exceptions are arising. How can i overcome this issue?

      G. Satish

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      Did you try Server.MapPath() function? http://msdn.microsoft.com/en-us/library/ms524632.aspx[^]

      Parwej Ahamad ahamad.parwej@gmail.com

      S 1 Reply Last reply
      0
      • P Parwej Ahamad

        Did you try Server.MapPath() function? http://msdn.microsoft.com/en-us/library/ms524632.aspx[^]

        Parwej Ahamad ahamad.parwej@gmail.com

        S Offline
        S Offline
        Satish Developer
        wrote on last edited by
        #3

        Yes. I tried now by using Server.MapPath(). But still same problem loosing sessions and static variables becoming null.

        G. Satish

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups