There is a POST request on login page which, for some reason, doesn't work. Code for the request is
$(document).ready(function () {
$.post(path, {param: "val"});
});
The method for getting this POST and working around it is the following:
[HttpPost]
public ActionResult Func(string val)
{
... //some stuff happening
return new EmptyResult();
}
Basically a standard method. Thing is, the method isn't called (most of the times) when I'm sending this POST from login page. However, when I log in and try to send it, the method works as intended. So is there any connection between sending POST request and being authorised?
CodePudding user response:
when I log in and try to send it, the method works as intended.
Sounds like you have an Authorize
filter on your method or controller.
Authorization filters can be applied to actionresults or controllers to only allow logged-in users to access those endpoints.
CodePudding user response:
you have a bug in you login script
replace
$.post("/Account/SetLang", {lang: lang});
with
$.post("/Account/SetLang", {val: lang});