azure - Azure, MVC Core Web App suddenly throw "XmlException: Root element is missing" + "CryptographicException"
问题描述
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.
Does anyone know how to solve this?
public AccountController(
UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> signInManager,
IEmailSender emailSender,
ILogger<AccountController> logger,
ApplicationDbContext context)
{
_userManager = userManager;
_signInManager = signInManager;
_emailSender = emailSender;
_logger = logger;
_context = context;
}
解决方案
好的,所以我自己发现了问题。在深入研究 Azure 中可用的调试快照后,我得到一个提示,即应用程序试图获取导致异常的 xml 的目录是“D:\home\ASP.NET\DataProtection-Keys”。当我分析该目录的内容时,我看到一个 xml 文件是空的。我删除了那个文件。这解决了问题。
推荐阅读
- c++ - 斐波那契记忆 - 通过左值与右值参考传递
- reactjs - React - 我不能将我的 datepicker 值作为参数传递,因为它是一个对象,我似乎无法将它转换为字符串
- vagrant - 如何使用转发端口访问 vagrant 容器端口?
- javascript - 在 javascript 中添加到 Firebase Cloud Messaging 的 channel_id 是什么?
- excel - 复制到另一张工作表时 Excel VBA 跳过空白
- google-coral - winpty: 错误: 无法启动'mdt': Not found in PATH [Mendel Development tool]
- image - 如何显示从 google colab 中解压缩的 google drive 文件夹中选择的图像
- python - TypedDict 的 Python typehint 子集(部分)
- stored-procedures - 调用存储过程抛出错误时如何使任务失败
- python - 如何正确导入测试类以继承,而不将其作为测试运行