question

FreningenLillngar-4640 avatar image
0 Votes"
FreningenLillngar-4640 asked ·

Server exceptions : "XmlException: Root element is missing" + "CryptographicException: An error occurred while trying to encrypt the provided data", After Azure portal updates.

I have a web application hosted by an Azure App service. It has worked fine for years but suddenly I get an Exception when i try to enter the Account/login action: -->"XmlException: Root element is missing" + "CryptographicException: An error occurred while trying to encrypt the provided data".
If i got to Home/About action (which have [AllowAnonymous] attribute) that page works fine. But if i try to enter a page within the Account controller which have the [AllowAnonymous] attribute. That also throw the same Exception. So I am guessing the Exception occur in the constructor for the Account controller. See below.

I have not made any updates to the page in months and it has worked fine until now. If I run the application locally on my PC (connected to the same database on azure) it works fine. As I understand Azure have recently made updates to their portal. My guess is that the cause of the error is related to that.
Can you please help me solve this!

 Constructor:
 public AccountController(
         UserManager userManager,
         SignInManager signInManager,
         IEmailSender emailSender,
         ILogger logger,
         ApplicationDbContext context)
     {
         _userManager = userManager;
         _signInManager = signInManager;
         _emailSender = emailSender;
         _logger = logger;
         _context = context;
     }
azure-webapps
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @FreningenLillngar-4640, I don’t believe the issue with your AccountController. Could provide the stack trace of your CyrptographicException? I believe the error is occurring with loading data. Are you using a file or database to store the user accounts?

0 Votes 0 ·

1 Answer

xequence avatar image
0 Votes"
xequence answered ·

Do you have parameters on your [AllowAnonymous] method? Typical account controller is setup to [Authorize] at the class level [Authorize] public class AccountController { ... }and each method that should allow anonymous (register, login) would [AllowAnonymous]. If it works on your box then there is something wrong with the deployment in relation to MSBuild. (check bindings in web.config)

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.