title: How to authenticate a xml in c#?
body: <p>I'm developing a webservice in asp.net and c#, which shows the content of the password protected XML file at <a href="http://www.pointstreak.com/xml/GET/schedule_11200.xml" rel="nofollow">poinstreak.com</a>. My problem is that I can't seem to get the authentication to work (I keep getting a 401 status). Any suggestions on how to solve this?</p>
  
  <pre><code>    protected void dataBind()
      {
          //Variables
          string xmlfile = "http://www.pointstreak.com/xml/GET/schedule_11200.xml";
          string xslfile = "/StyleSheet/XSLT/xslForGETMatches.xsl";
  
          //Credentials
          NetworkCredential myCred = new NetworkCredential("username", "password");
          CredentialCache myCache = new CredentialCache();
          myCache.Add(new Uri(xmlfile), "Basic", myCred);
  
          //Set the credentials on the XmlUrlResolver object
          XmlUrlResolver resolver = new XmlUrlResolver();
          resolver.Credentials = myCache;
  
          //XSL Transformation
          XslCompiledTransform xslt = new XslCompiledTransform();
          xslt.Load(xslfile, XsltSettings.Default, resolver);
          StringBuilder outfile = new StringBuilder();
          XmlWriterSettings settings = xslt.OutputSettings.Clone(); 
          settings.CheckCharacters = false;
          xslt.Transform(xmlfile, XmlWriter.Create(outfile, settings));
          xmlToHtmlOutput.Text = outfile.ToString(); //An ASP Label
      }
  </code></pre>