Why Azure Web App not starting when I add maxAllowedContentLength in web.config? - azure

I'm developing ASP.NET 7 WebApi app which is hosted on Azure Web App. I need to transfer large files. Many resources show that I need to add node in web.config, but when I add, my azure web app won't start.
My web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\WebApplication1.dll" stdoutLogEnabled="false"
stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647 " />
</requestFiltering>
</security>
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 46edd0a7-6184-47ed-a0e9-d3be7fee8b41-->
And this message is shown when I try to open web app.
As in title: Why it's not working? Do I missed some step?

Related

blazor server app 404 on publish at / on IIS

I have a blazor app that is running fine on localhost.
Here's the steps I have taken to put my project live.
Setup new Windows Server on AWS.
Enabled IIS.
Installed ASP.NET Core Runtime Hosting Bundle.
Installed the URL Rewrite module.
Setup a SSL cert and DNS settings to point to IP.
Configured bindings to port 443 and picked the cert added path wwwroot/projectname
published my project using web deploy.
However, when navigating to my url I'm seeing 404 resource not found.
Only thing that is different is that the server added a web config to get it to run in IIS which looks like this.
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 8b081fc5-0f9d-4426-b9cf-90f4d30b5527-->
Anyone point me in the right direction as to what I should be looking out for or steps I may have missed as this is the first time I've attempted publishing a Blazor-Server application.
On my IIS, I have "AspNetCoreModuleV2" not "AspNetCoreModule" like this:
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 8b081fc5-0f9d-4426-b9cf-90f4d30b5527-->
See: Hosting A Blazor Visual Studio Project Directly In IIS

ASP.NET Core 3 - Is there a way to add Module section to produced Web Config File

Like said in the title i'm publishing an ASP.NET Core 3 API to IIS. When i publish that API the system create a web config file in the deploy directory containing that :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\xxxxx.Api.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: daddb75b-3c54-4970-8945-8404ade81fbc-->
Everything is ok but what's i want to do is to add the three lines below in the System.webServer section in order to cover the issue described in this link : https://fantinel.dev/net-core-api-method-not-allowed-on-put-and-delete-requests/
Extract for explanations :
What happens is that, when published, .NET Core enables the
WebDAVModule, which disables PUT and DELETE requests by default.
So to get PUT and DELETE verbs we have to disable this WebDAVModule with this lines :
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
Is there a way to automatize the include of this lines to the produced/published web.config ? In the VS solution i don't see any Web.Config file or option to drive the output of deploy.
Thanks you all for your advices.
I just found out that when you add a web.config file yourself, the publishing wizard combines the normally generated web.config with the file you define yourself. Eg:
No web.config ==> Produces following web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\MintPlayer.Web.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 7b031640-46da-4eac-b60c-740bd3659fce-->
Following web.config in the root of your ASP.NET Core project
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
</system.webServer>
</location>
</configuration>
Produces following web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
<aspNetCore processPath=".\MintPlayer.Web.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
So it seems that the ASP.NET Core deployment is combining both xml's. I'm using ASP.NET Core 3.1.

Is it possible to have 2 ASP.NET Core sites in one Web App?

Is it possible to have 2 ASP.NET Core Web API apps inside the one App Service?
I understand that it would be better to have the 2 sites in separate App Services, but our use case is a bit unique.
We're trying to add the 2nd site for the purposes of using the applicationInitialization feature to introduce a delay between our app starting and the instance being given to the App Service load balancer.
I could go into a lot more detail on this, but what I desire for now is to bolt-on an additional web site that the applicationInitialization can call to delay the startup process.
I've tried:
Folder structure:
/mySite
/mySite2
web.config
Folder structure:
/mySite2
mySite.dll
web.config
With respective web.Configs looking like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="mySite" inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mysite\mySite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
<location path="mySite2" inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mySite2\mySite2.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
</configuration>
and
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mySite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
<location path="mySite2" inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mySite2\mySite2.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
</configuration>
YES. It is possible, you can have two applications on a single web app with a virtual directory.
From docs:
Virtual Directories are supported for Azure Websites. See Configuring
Azure Websites for what you can do through the Azure Management
Portal. From the Azure Portal, click on the Website and go to
Configure, then scroll down to virtual applications and directories
(the last config section). Just enter your virtual directory and the
physical path relative to the site root and click Save.

Azure: App Service: Deploy Virtual Directory

I have an asp.net core app deployed on azure website and the domain is www.somewebsite.org. My web.config file is under site\wwwroot\web.config. Its contents are
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App1.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout">
<environmentVariables>
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
I am trying to deploy another asp.net core app with the virtual path www.somewebsite.org/kiosk and I copied the complete directory under site\wwwroot\kiosk and the web.config file is under site\wwwroot\kiosk\web.config. Its contents are:
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Kiosk.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
On Azure portal, in Application Settings for my site, I have
/ - site\wwwroot
/kiosk - site\wwwroot\kiosk
When I try going to www.somewebsite.org, the app1 site is loaded whis is correct. But, when I go to www.somewebsite.org/kiosk, the kiosk app is not being loaded. The page comes back with a 500 Internal Server Error. How do I fix this error? Is it even possible to host multiple apps from separate multiple virtual paths under one website in azure?
In my sub-application web.config file, I did the following and it started working:
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore_TEMP" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Kiosk.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Now, both the sites are up.
Thanks for your help.
NH
I reproduce your error, and you just need to add <location path="." inheritInChildApplications="false"> in you web.config file which is under site\wwwroot\web.config.
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App1.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout">
<environmentVariables>
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>

Run go web application on IIS

Is there a way to run Go web application on IIS?
I found a setting for azure but its not working on my dev machine
this is a web config for azure :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="d:\home\site\wwwroot\go\bin\go.exe"
arguments="run d:\home\site\wwwroot\server.go"
startupTimeLimit="60">
<environmentVariables>
<environmentVariable name="GOROOT" value="d:\home\site\wwwroot\go" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Your local IIS does not work simply because you need to install a separate component, called HttpPlatformHandler module,
https://azure.microsoft.com/en-us/blog/announcing-the-release-of-the-httpplatformhandler-module-for-iis-8/
http://www.iis.net/downloads/microsoft/httpplatformhandler
Reverse proxy or FastCGI were the older approaches which are no longer necessary with this new approach.
HttpPlatformHandler module doesn't work for me. I found this post by Sutean Rutjanalard on Medium very helpful, which use ASP.NET Core Module instead.
Basically, you need to create Application pool with "No Managed Code" as you do with a .net core app. And the following is the web.config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\YourGoApp.exe" />
</system.webServer>
</configuration>

Resources