Open Closed

Uncaught TypeError: Cannot read property 'antiForgery' #3518


0
kythor created

Hi,

after upgrading to version 1.0.0.0 I get this error when loading the site:

Cannot read property 'antiForgery' of undefined

coming from abp.js

(function(){
    abp.security.antiForgery.tokenCookieName = 'XSRF-TOKEN';
    abp.security.antiForgery.tokenHeaderName = 'X-XSRF-TOKEN';
})();

any help would be appreciated. thx.


7 Answer(s)
  • 0
    alper created

    hi

    the correct code

    abp.security = abp.security || {};
        abp.security.antiForgery = abp.security.antiForgery || {};
    
        abp.security.antiForgery.tokenCookieName = 'XSRF-TOKEN';
        abp.security.antiForgery.tokenHeaderName = 'X-XSRF-TOKEN';
    
  • 0
    kythor created

    ok, I updated the complete folder "Abp", so the right updated .js files are used.

    but when I try to login now, I get this error:

    Request URL:.../Account/Login?returnUrl=
    Request Method:POST
    Status Code:400 Empty or invalid anti forgery header token.
    

    what else am I missing?

    Request header has this at the end:

    X-Requested-With:XMLHttpRequest
    X-XSRF-TOKEN:null
    

    should it be Null or does it need to contain a value?

  • 0
    ismcagdas created

    Hi @Kythor,

    Which version of AspNet Zero Do you use ? Angular1, Angular2, MVC 5.x with jQuery or ASP.NET Core with jQuery ?

    Thanks.

  • 0
    kythor created

    using MVC & jQuery, downloaded in august 2016, so a lot has been changed. abp.js was changed, so to be sure, I copied & overwrite the whole ABP folder on production.

    I have found some suggestions about clearing the cookies, but this shouldnt be needed, because its still the same domain, and I dont want my visitors to do that before they can login. https://github.com/aspnetboilerplate/as ... ssues/2049

  • 0
    ismcagdas created

    Hi,

    You should also add this line to your _Layout.cshtml file https://github.com/aspnetzero/aspnet-ze ... .cshtml#L5

    It sets antiforgery cookie.

    thanks.

  • 0
    kythor created

    this link doesnt work

  • 0
    ismcagdas created

    Hi @Kythor,

    It is in private repository. You should login to github wih your username.

    If you haven't share your github username with us, please share your username and we will invite you.

    Thanks.