title: WebClient Lost my Session
body: <p>I have a problem first of all look at my web service method :</p>
  
  <pre><code>[WebMethod(EnableSession = true), ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public string GetPageContent(string VirtualPath)
  {
      WebClient client = new WebClient();
      string content=string.Empty;
      client.Encoding = System.Text.Encoding.UTF8;
      try
      {
          if (VirtualPath.IndexOf("______") &gt; 0)
              content = client.DownloadString(HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace("Main.aspx", VirtualPath.Replace("__", ".")));
          else content = client.DownloadString(HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace("Main.aspx", VirtualPath));
      }
      catch { content = "Not Found"; }
      return content;
  }
  </code></pre>
  
  <p>As you can see my web service method read and buffer page from it's localhost it works and I use it to add some ajax functionality to my web site it works fine but my problem is Client.DownloadString(..) lost all session because my sessions are all null which are related to this page for more description. at page-load in the page which I want to load from my web service I set session :</p>
  
  <pre><code>HttpContext.Current.Session[E_ShopData.Constants.SessionKey_ItemList] = result;
  </code></pre>
  
  <p>but when I click a button in the page this session is null I mean it can't transfer session.</p>
  
  <p>How I can solve this problem ?
  my web service is handled by some jquery code like following :</p>
  
  <pre><code>$.ajax({ type: "Post",
      url: "Services/NewE_ShopServices.asmx" + "/" + "GetPageContent",
      data: "{" + "VirtualPath" + ":" + mp + "}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      complete: hideBlocker,
      success: LoadAjaxSucceeded,
      async: true,
      cache: false,
      error: AjaxFailed
  });
  </code></pre>
  
  <p>Web Client causes to lose session and .js files can not run how I can use other thing instead of web client with the same practical application ?</p>