Skip to content
Loading
401 unauthorized in ajax call
  • I have set this attribute it's again same error showing.
    +2
  • Sachin Singh
    yes correct.
    +2
  • This type Right?
    [AllowAnonymous]
    public JsonResult OnGetAPIOption()
    {
    var appKey = _config.GetValue("AuthenticationKey:applicationKey");
    return new JsonResult(appKey);
    }
    +2
  • Sachin Singh
    Add the attribute [AllowAnonymous] over OnGetAPIOption()
    +2
  • Sir I have not set any token
    +2
  • This is my .cs file code
    public JsonResult OnGetAPIOption()
    {
    var Key = _config.GetValue("ABC");
    return new JsonResult(Key);
    }
     
     This is my ajax call function
    function getOptionKey() {
    $.ajax({
    url: '/APICallFile?handler=APIOption',
    async: false,
    contentType: "application/json; charset=utf-8",
    success: function (response) {
    }
    });
    }
    getOptionKey();
     This issue face
    1. Request Method:
      GET
    2. Status Code:
      401
     
    +2
  • Sachin Singh
    You are not passing token.
    +2