Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 197 Vote(s) - 3.72 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASP.NET Calling WebMethod with jQuery AJAX "401 (Unauthorized)"

#11
In my case the problem was in URL that calls Ajax.asmx this URL was not correct according to a webserver setup, e.g. `"/qa/Handlers/AjaxLib.asmx/"` worked for me instead of `"/Handlers/AjaxLib.asmx/"` (works fine on PROD servers in my particular situation):

$.ajax({
url: '/qa/Handlers/AjaxLib.asmx/' + action,
type: "POST",
async: false,
data: data,
contentType: "application/json; charset=utf-8",
success: function () {

My AJAX was then called out of scope of my IIS virtual application directory "qa", hence Authorization error occured `({"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}).`
Reply

#12
You have to comment out only in ~/App_Start/RouteConfig.cs

// settings.AutoRedirectMode = RedirectMode.Permanent;

(Or do this)

settings.AutoRedirectMode = RedirectMode.Off;

There is nothing to do with Authentication in Web.config file.
Reply

#13
To allow this Web Service to be called from script, using ASP.NET AJAX. Add the following attribute to the class

[System.Web.Script.Services.ScriptService]


I faced similar issue and the adding this attribute resolved it.

Reply

#14
For me, I had an invalid "data:" parameter in my JQuery Ajax call. But rather than either .NET or JQuery complaining about the the parameter values, I was (misleadingly in my opinion) getting the 401 Unauthorized error.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through