title: Open X509 Certificates Selection Using USB Token in C# Hosted on IIS
body: <p>I am working on a requirement which required Digital Signature on PDF files in ASP.Net C# and developed one application who gets the client certificate using USB token on my local machine. But, When hosting this application on IIS server getting error <strong>'Current Session is not Interactive'</strong>.</p>
  
  <p>Anyone have any idea, how can we get X509Certificates from client machine in ASP.Net C# and this application hosted on IIS server not console application.</p>
  
  <p>My code for reference:</p>
  
  <pre><code>private void getSign()
  {
      X509Store store = new X509Store(StoreLocation.CurrentUser);
      store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
      X509Certificate2 cert = null;
      //manually chose the certificate in the store
      X509Certificate2Collection sel = X509Certificate2UI.SelectFromCollection(store.Certificates, null, null, X509SelectionFlag.SingleSelection);
      if (sel.Count &gt; 0)
          cert = sel[0];
      else
      {
          //MessageBox.Show("Certificate not found");
          return;
      }
      SignWithThisCert(cert);
  }
  </code></pre>