title: Add a web service (ASMX) to existing asp.net forms website
body: <p>I'm trying to create a web service in an existing asp.net web forms application, but it isn't working.  The following code describes the service: </p>
  
  <pre><code>[WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  public class TestService: System.Web.Services.WebService {
  
      public TestService() {
  
          //Uncomment the following line if using designed components 
         //InitializeComponent(); 
      }
  
      [WebMethod]
      public string HelloWorld(string name) {
          return "Hello " + name;
      }    
  }
  </code></pre>
  
  <p>When I try to test this web service, the browser tries to download the service instead of executing it:</p>
  
  <p><img src="https://i.stack.imgur.com/bM0qk.png" alt="service"></p>
  
  <p>Also, if I try to reference the service from another project, I get the following error:</p>
  
  <p><em>The document at the url <code>http://localhost:64925/services/TestService.asmx</code> was not recognized as a known document type.
  The error message from each known type may help you fix the problem:
  - Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=utf-8</em></p>
  
  <p>My guess was that it was something to do with the 'services' directory not being configured properly but I get the same issue if the service is added to the root of the site.</p>
  
  <p>I have tried aspnet_regiis for both .Net 2 &amp; 4
  I'm using Visual Studio 2012 with IIS Express.</p>
  
  <p><strong>Update:</strong>
  It appears that the website is also referencing SharePoint webservices and I have just spotted the following weird message in the error details:</p>
  
  <p><em>There was an error downloading <code>http://localhost:64925/services/TestService.asmx/_vti_bin/ListData.svc/$metadata</code>.
  The request failed with HTTP status 404: Not Found.</em></p>