title: httpContext.Current.Session is null (Inside WebService) Asp.net
body: <p>I have an web service.And i am using some session variables in that service.</p>
  <h2>Code:</h2>
  <pre><code>[WebMethod(EnableSession = true)]
  public static string UploadFiles_Local(Dictionary&lt;int, string&gt; accFile)
  {
      string FilePath = &quot;&quot;;
      Dictionary&lt;int, string&gt; dicStatus = new Dictionary&lt;int, string&gt;();
      Dictionary&lt;int, string&gt; dicUpload = new Dictionary&lt;int, string&gt;();
  
      System.Web.HttpContext.Current.Session[&quot;uLocal&quot;] = System.Web.HttpContext.Current.Server.MapPath(&quot;UplodedFiles&quot;) + &quot;\\&quot; + DateTime.Now.Ticks.ToString();
  
      foreach (var f_l in accFile)
      {
          FilePath = f_l.Value;
          string fName = FilePath.Substring(FilePath.LastIndexOf(&quot;\\&quot;) + 1, FilePath.Length - FilePath.LastIndexOf(&quot;\\&quot;) + 1);
  
          //File reading
          FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read);
          //Directory Existens checking
          if (!Directory.Exists(System.Web.HttpContext.Current.Session[&quot;uLocal&quot;].ToString()))
          {
              Directory.CreateDirectory(System.Web.HttpContext.Current.Session[&quot;uLocal&quot;].ToString());
          }
          try
          {
              //Upload files
              long FileSize = new FileInfo(FilePath).Length; // File size of file being uploaded.
              string uploadFileName = new FileInfo(FilePath).Name; // File name
  
              Byte[] buffer = new Byte[FileSize];
              fs.Read(buffer, 0, buffer.Length);
              fs.Close();
              fs = null;
  
              fs = File.Open(System.Web.HttpContext.Current.Session[&quot;uLocal&quot;].ToString() + &quot;\\&quot; + fName, FileMode.OpenOrCreate);
              BinaryWriter bw = new BinaryWriter(fs);
              bw.Write(buffer);
              bw.Close();
  
              dicStatus.Add(f_l.Key, &quot;File &quot; + fName + &quot;. Successfuly uploded to:&quot; + System.Web.HttpContext.Current.Session[&quot;uLocal&quot;].ToString() + &quot;\\&quot; + fName);
              dicUpload.Add(f_l.Key, System.Web.HttpContext.Current.Session[&quot;uLocal&quot;].ToString() + &quot;\\&quot; + fName);
          }
          catch (Exception ex)
          {
              if (fs != null)
              {
                  fs.Close();
              }
              dicStatus.Add(f_l.Key, &quot;File &quot; + fName + &quot;. Error in uploding to:&quot; + System.Web.HttpContext.Current.Session[&quot;uLocal&quot;].ToString() + &quot;\\&quot; + fName + &quot;\r\nError :&quot; + ex.Message);
          }
          finally
          {
              if (fs != null)
              {
                  fs.Close();
              }
          }
      }
      if (dicUpload.Count &gt; 0)
      {
          //Making rar of uploded files
          ClsClass.RarFilesT(System.Web.HttpContext.Current.Session[&quot;uLocal&quot;].ToString() + &quot;.rar&quot;, dicUpload);
          FilePath = System.Web.HttpContext.Current.Session[&quot;uLocal&quot;].ToString() + &quot;.rar&quot;;
      }
      else
      {
          FilePath = &quot;Error&quot;;
      }
      return FilePath;
  }
  </code></pre>
  <p>I have already enabled session in that web service but stile i get error message :-</p>
  <h2>Error message:-</h2>
  <pre><code> 'System.Web.HttpContext.Current' is null 
  </code></pre>
  <p>And one more ting i need to call this service from globle.ashx file.</p>