title: Call asmx webservice from MVC view
body: <p>People, I'm trying to call an asmx service from an MVC view.</p>
  
  <p>The code in asmx looks like:</p>
  
  <pre><code>[WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [ToolboxItem(false)]
  [ScriptService]
  public class MyService : WebService
  {
      [WebMethod]
      public string SomeMethod()
      {
          return "hello world";
      }
  }
  </code></pre>
  
  <p>the ajax call in the mvc view is:</p>
  
  <pre><code>$(document).ready(function () {
      $.ajax({
          type: "GET",
          url: "MyService.asmx/SomeMethod",
          data: "{}",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (msg) {
              alert('success');
          },
          error: function (e) {
              alert('error: ' + e.msg);
          }
      });
  });
  </code></pre>
  
  <p>But i'm always getting an 'undefined' error.  With fiddler enabled i figured out that the webservice couldn't be found (The resource cannot be found).</p>
  
  <p>Any help appreciated</p>
  
  <p>EDIT:</p>
  
  <p>Ok, i got it working.  I needed to add following line to my RouteConfig:</p>
  
  <pre><code>routes.IgnoreRoute("{*x}", new { x = @".*\.asmx(/.*)?" }); 
  </code></pre>