0

I am trying to call a web method using jQuery and having same issue as this question, but I am working with ASP.Net 3.5 web forms, and don't have ~/App_start/routeconfig.cs.

How can I fix this error with ASP.Net 3.5?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
shrekDeep
  • 2,260
  • 7
  • 27
  • 39
  • If you're getting a 401 error from a jQuery AJAX request the you need to include an `Authorization` header in the request, passing the auth token in whatever format is required. It's not a C# issue, unless you're not expecting to have any type of authentication at all, in which case you simply need to disable it. – Rory McCrossan Jul 25 '18 at 09:19
  • ok .. so this error is at the login page. as I said I am having exact same issue. – shrekDeep Jul 25 '18 at 09:22
  • have you tried this to send the session: [WebMethod(EnableSession = true)] – SehaxX Jul 25 '18 at 09:35
  • @SehaxX, yes already tried that – shrekDeep Jul 25 '18 at 09:37

2 Answers2

0

For doing that, you can adding below code in web.config:

<authorization>
   <allow users="*" />
</authorization>

For more information, please see allow Element for authorization.

Ali Soltani
  • 9,589
  • 5
  • 30
  • 55
0

If the problem is really in authorization, then try to allow an anonymous access to your login page in web.config:

<location path="Login.aspx">
  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
</location>
AlbertK
  • 11,841
  • 5
  • 40
  • 36