Hello
I am developing a Module with DnnApiController and I created a class:
public class AuthController : DnnApiController
{
[HttpPost]
[HttpGet]
[AllowAnonymous]
public HttpResponseMessage LoginCustomer(string userName, string password, bool rememberMe) {
{ ... }
}
}
When I pass parameters by POST, I receive the error:
{"Message":"No HTTP resource was found that matches the request URI 'http://dnndev.me/DesktopModules/ShapeLovers.DNNShapeLovers/API/Auth/LoginCustomer'.","MessageDetail":"No action was found on the controller 'Auth' that matches the request."}
Now, if I test the method by GET it works fine, here is my ajax call:
function doAuthentication() {
var iuserName = $("#login_username").val();
var iuserPassword = $("#login_password").val();
var irememberMe = $("#remember_me").val();
var moduleScope = $('#<%=ScopeWrapper.ClientID %>');
var sf = $.ServicesFramework(<%=ModuleId %>);
$.ajax({
type: "GET",
url: sf.getServiceRoot('ShapeLovers.DNNShapeLovers') + "Auth/LoginCustomer",
data: { userName: iuserName, password: iuserPassword, rememberMe: (irememberMe == 'on') },
beforeSend: sf.setModuleHeaders
}).done(function (data) {
data.result);
}).fail(function (xhr, result, status) {
Uh-oh, something broke: " + status + " - " + result + " + " + xhr);
});
}
Everything work fine using
GET, but no
POST!!!
I appreciated your help, there is very poor documentation in internet about DNN WebAPI
By Fiddler I check the request is formed like this:
==========================================================================================================
POST http://dnndev.me/DesktopModules/ShapeLovers.DNNShapeLovers/API/Auth/LoginCustomer HTTP/1.1
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
ModuleId: 414
TabId: 87
__RequestVerificationToken: uACEnFjnC1PKFK-oRtYOgwUVTq5zhNvRyFmgw4PuB3ZDOR_YXjvTIZAw0XWusOtO6mNf0znwzsg1itAabKfXjjv3L3Wm6MGazv5BRzZxKeQ-oieG6t4oNvqFssw1
X-Requested-With: XMLHttpRequest
Referer: http://dnndev.me/CLogin.aspx
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Host: dnndev.me
Content-Length: 46
Connection: Keep-Alive
Pragma: no-cache
Cookie: .ASPXANONYMOUS=AjglvipHzgEkAAAAZDJjMTM3ZWEtOGYxNi00MTMyLTljYjAtOWU3NTQ5OGRiNzk10; ASP.NET_SessionId=yz25hd2ufczgdpbmtb5jvmak; language=en-US; __RequestVerificationToken=Iqv0eiZVz-AQKzF3h8oOa3A749wovGen9uquia7K8H6oeHF1Sr5rUBMCm_MDziTPIms0iwxtjjbHef1ubUtxAWtECp7oO3YEn6M7YGDjodaRJ9BN1G-pUigb-YI1
userName=rdewfw&password=gwere&rememberMe=True
==========================================================================================================