Ошибка аутентификации во время вызова webmethod из jquery.ajx с AspNet.FriendlyUrls и AspNet.Identity
Если я вызываю webmethod из jQuery.Ajax с установленными пакетами Nuget Microsoft.AspNet.FriendlyUrls v 1.0.2 и Microsoft.AspNet.Identity v.1.0.0., Тогда я получаю объект данных, но без data.d, но со свойством Message 'Ошибка аутентификации ».
Мой Webmethod.aspx это:
WebMethod
Test Webmethod
function asyncServerCall(username) {
jQuery.ajax({
url: 'WebMethod.aspx/HelloWorld',
type: "POST",
data: "{'username':'" + username + "'}",
//async: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
if (data.d == undefined)
document.getElementById("greeitng").innerHTML = data.Message;
else
document.getElementById("greeitng").innerHTML = data.d;
},
error: function (err) {
if (err.responseText) {
$('#innerError').html(err.responseText).show();
}
else {
alert(err);
}
}
});
}
$(document).ready(function () {
$('#innerError').hide();
asyncServerCall("Superuser");
});
Мой веб-метод в WebMethod.aspx.cs:
[System.Web.Services.WebMethod]
public static string HelloWorld(string username)
{
return string.Format("Hello, {0}", username);
}
В Global.asax.cs включена маршрутизация
void Application_Start(object sender, EventArgs e)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
В App_Start прописали свои маршруты
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);
}
}