I keep getting a 405 Method not allowed. The script is hosted on same port as server, using IIS.
<script>
function auth() {
var str= '{"Password":"Password","Username":"Username"}';
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://127.0.0.1:8080/auth/authenticate",
data: str,
success: function(data) { alert(data) },
dataType: "json"
});
}
</script>
Web Service
[WebInvoke(UriTemplate = "auth/authenticate", Method = "POST")]
public AuthenticationReturn Authenticate(AuthenticationCredentials credentials)
{
try
{
AuthenticationReturn ad = new AuthenticationReturn();
DateTime now = DateTime.Now;
ad.AuthorizationToken = "some_string_" + now.Ticks.ToString();
ad.UserIdentifier = "some_identifier_" + now.Ticks.ToString();
ad.Expiration = now.AddYears(1);
return ad;
}
catch (InvalidOperationException ioe)
{
throw new WebFaultException<InvalidOperationException>(ioe, System.Net.HttpStatusCode.BadRequest);
}
}