title: Origin http://localhost is not allowed by Access-Control-Allow-Origin
body: <p>I'm trying to call a webservice from my local machine. But the I get the following errors in Chrome console:<br>
  <code>http://www.test.com/service.svc/api/?cid=1 405 (Method Not Allowed) 
  XMLHttpRequest cannot load http://www.test.com/service.svc/api/?cid=1.<br>
  Origin http://localhost is not allowed by Access-Control-Allow-Origin.</code></p>
  
  <p>My local test URL is: 
  <code>http://localhost/welcome/html/index.html</code></p>
  
  <p>When I upload my code to the actual domain and call the webservice from there, it does work ofcourse.</p>
  
  <p>I've already tried to change the access control headers, but that doesnt help.</p>
  
  <pre><code>Namespace RestService
  
  Public Class service
      Implements Iservice
  
      Public Function GetProvinces(ByVal cid As String) As AjaxControlToolkit.CascadingDropDownNameValue() Implements Iweddingservice.GetProvinces
          WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Methods", "DELETE, POST, GET, OPTIONS")
          WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin", "*")
  
          Dim MyConnection As SqlConnection = GetConnection()
          Dim cmd As New SqlCommand("SELECT provinceid,title FROM provinces WHERE CountryID=@CountryID ORDER BY title ASC", MyConnection)
          cmd.Parameters.Add(New SqlParameter("@CountryID", cid))
          Dim values As New List(Of CascadingDropDownNameValue)
          Try
              MyConnection.Open()
              Dim reader As SqlDataReader = cmd.ExecuteReader
              While reader.Read
                  values.Add(New CascadingDropDownNameValue(reader("title").ToString, reader("provinceid").ToString))
              End While
          Catch ex As Exception
  
          Finally
              MyConnection.Close()
          End Try
          Return values.ToArray
      End Function
  
  End Class
  
  
  End Namespace       
  </code></pre>