I have an MVC project built in .Net Core 2.2 for Azure. The project runs locally, but when I upload it to Azure, I receive an error that I do not have permission to read this file or directory, and none of the pages are accessible. If I remove the
web.config file from the project, rebuild and upload again, it works. I can also attach an empty web.config and that also works.
With asp.net core, the web.config is for configuring the core module. The <location> and <system.web> Are not supported. You should only have <system.webServers> And use it to configure asp.net core module.
Member
1 Points
3 Posts
Azure MVC, adding web.config blocks access to website
Jan 28, 2020 02:24 PM|Terry Stone|LINK
I have an MVC project built in .Net Core 2.2 for Azure. The project runs locally, but when I upload it to Azure, I receive an error that I do not have permission to read this file or directory, and none of the pages are accessible. If I remove the web.config file from the project, rebuild and upload again, it works. I can also attach an empty web.config and that also works.
THIS WORKS
THIS DOES NOT WORK
The path "EditPhrase/BuildPartial" is a POST action in the controller EditPhraseController.
Contributor
3710 Points
1043 Posts
Re: Azure MVC, adding web.config blocks access to website
Jan 29, 2020 04:01 AM|Yongqing Yu|LINK
Hi Terry,
As far as I know, just because you published to azure, the path has changed.
You need to change your path to a virtual path, like below:
For more details, you could refer to these links:
How To Make Application and Directory-Specific Configuration Settings in an ASP.NET Application
Location + Path in web.config not working in Azure
Best Regards,
YongQing.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
1 Points
3 Posts
Re: Azure MVC, adding web.config blocks access to website
Jan 29, 2020 11:23 AM|Terry Stone|LINK
Thank you for your reply. Adding the location marker '~' did not help.
After the web.config is published to Azure, it changes to the following:
The publishing process has added new tags for "handlers" and "aspNetCore" to one of the locations, but no the other.
All-Star
58164 Points
15647 Posts
Re: Azure MVC, adding web.config blocks access to website
Jan 29, 2020 03:15 PM|bruce (sqlwork.com)|LINK
With asp.net core, the web.config is for configuring the core module. The <location> and <system.web> Are not supported. You should only have <system.webServers> And use it to configure asp.net core module.
Member
1 Points
3 Posts
Re: Azure MVC, adding web.config blocks access to website
Jan 31, 2020 01:40 PM|Terry Stone|LINK
Thank you for the reply. Yes, the following works on both the development server and Azure:
But it does apply to the whole website. Is it possible to limit the exceptional request limits to specific locations?
All-Star
58164 Points
15647 Posts
Re: Azure MVC, adding web.config blocks access to website
Jan 31, 2020 04:50 PM|bruce (sqlwork.com)|LINK
you would need to use asp.net core middleware to do this.
note: browsers (and proxy servers) often limit the url + query string length to 4k (2k if unicode), not sure why you are setting such high values.