-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnauthorizedAccessException when running on Azure Web App service #143
Comments
Hi, whats the NET version you use? The exception happens here so the actual problem I believe in compiling template and its references. My first guess is to go ang check whether there are any tricky dependencies of a class library (if any) |
Hi Alexander. Thanks very much for your helpful reply. We are using .NET 8.0. The failing templates do not reference any assemblies, although they do subclass RazorEngineTemplateBase, in order to implement your recommended pattern for accessing partial templates. As mentioned above, I have seen this pattern working correctly, when implemented in the ASP.NET Core root Web API project, but the same code fails when it exists in a class library. As you suggested, I will create a the simplest possible demo of the issue and post here again when this is ready. Thanks again. |
In case anyone else faces this issue, here is the solution that worked for me. The problem was entirely caused by using a low-tier Azure instance. When I upgraded to a higher tier (B1 or above) the issue disappeared. |
Tim, thank you very much for feedback! |
My implementation of RazorEngineCore works fine in my local Windows development environment, but throws UnauthorizedAccessException when deployed as part of an Azure Web App (on a Windows instance).
As the following exception message indicates, the issue arises during template compile:
Strangely, some templates work perfectly, while others throw the above exception, with seemingly no significant difference between their template structure or content.
I've tried multiple different ways of supplying the templates to RazorEngineCore, including embedded resource files and hard-coded strings, but all approaches suffer the same exceptions.
Interestingly, the problem only occurs when the RazorEngineCore implementation and the templates are defined in a class library. If I move these elements into the root ASP.NET Core Web API project, RazorEngineCore renders reliably.
If you have any suggestions, I would appreciate them. Many thanks.
The text was updated successfully, but these errors were encountered: