0

I have an angularjs based application hosted in an Azure App Service.

When the application loads in the browser, angularjs downloads a bunch of directive templates (static html files). Most of them download correctly (http 200) but some of them, randomly, result in a http 500 error.

If I try to access the direct url to the file that generates the 500 error, sometimes downloads correctly, sometimes don't.

I did compare cookies/headers/etc.. on both correct and failed requests and they are the same.

Using application insights, I found that the error happens validating an antiforgery token in this method: System.Web.Helpers.AntiXsrf.TokenValidator.ValidateTokens. Exception says that the antiforgery token was issued for a user that is not the current user.

The Azure App Service uses 6 fixed instances of the application. ARR Affinity is enabled and Always On is disabled.

Someone had a similar problem that can point me to fix this issue?

EDIT:

This is what happens in the client:

Errors shown in devtools

And sometimes, loading the same page, in the same machine, same browser, same user... the templates downloads ok:

Same requests with no errors

All templates are referenced in the same way:

var ngCModule = angular.module('ngC', ['ngD']);

ngCModule.directive('cont', function (Timezone) {
    return {
        restrict: 'E',
        ...
        templateUrl: "/Scripts/angular-templates/angular-contribuyente-template.html"
    }
});

The same application deployed in an on-premise IIS does not raise those errors.

L. González
  • 21
  • 1
  • 6
  • Please provide enough code so others can better understand or reproduce the problem. – Community Apr 22 '22 at 02:12
  • Check this SO thread-https://stackoverflow.com/questions/54442936/why-do-we-get-httpantiforgeryexception-after-publishing-update-to-azure-web-app?rq=1 – RKM Apr 22 '22 at 06:04

1 Answers1

0

We found that this strange problem was a side-problem caused by enable client side app insights monitoring.

When we configure in app service:

APPINSIGHTS_JAVASCRIPT_ENABLE = true

those strange http 500 error happens randomly.

After assign false to this parameter, there are not http 500 errors any more.

L. González
  • 21
  • 1
  • 6