I have created a demo Web Api in net6 using the Visual Studio 2022 template for that. The Web Api runs fine on my machine but when trying to host it in an Azure App Service it fails with the following error:
After some research I managed to have it working on Azure by changing the module "AspNetCoreModuleV2" to "AspNetCoreModule" in the web.config.
Here it is the web.config that gets deployed to Azure and it doesn't work:
<?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=".\Web6Test.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Is it possible to host the web api in Azure using the "AspNetCoreModuleV2" module?
There can be multiple reasons causing HTTP 500.30 error: ASP .Net core app failed to start like App Initialization, App Configuration and Key vault permission issues.
Thanks to 130nk3r5, I figured out how to find the root cause of the error:
Go to Azure Portal
Select App Services
Search and click on your App service
Go to development tools and open console.
Run the application through this console and then the real error that is causing the application not to load will be displayed.
You can refer to this SO thread for multiple solutions.
Hosting the web api can also be achieved by using AspNetCoreModuleV2 in the web.config.
I have reproduced the same by creating a .Net 6.0 Core web API project in Visual Studio.
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=".\XXXXXX.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 09e5e23c-101e-41d1-bd27-60c6f5c08db0-->
Output when running the project locally:
Deployed the application to Azure App Service:
Output after hosting the application in Azure App Service:
Result:
Related
I have created a HttpTrigger Azure function (.Net 6.0 Isolated-LTS) using Visual Studio 2022. I have published the Project in a Local Folder in my system. Try to deploy the generated dlls in the Local IIS and call the API from browser but getting error.
I have done all the steps provided in following link:
Is it possible to deploy the Azure Functions in Local IIS?
I have installed Azure Function Runtime and set processPath in web.config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="C:\Program Files\Microsoft\Azure Functions Core Tools\Microsoft.Azure.WebJobs.Script.WebHost.dll" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="AzureWebJobsStorage" value="UseDevelopmentStorage=true" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
I am still getting the following error:
HTTP Error 500.0 - ASP.NET Core IIS hosting failure (in-process)
I'm trying to host two applications in IIS in Windows Server 2019, in the same site. One of the applications is a website's front-end, in Angular, and the other one is the website's API, in ASP.NET MVC (.NET Core 2.2.8).
The front-end application's URL is site_url/portal and the API's is site_url/api.
Before using the API's other actions, one has to request a JSON web token from the site_url/api/identity URL, using Windows Authentication.
The front-end seems to be working fine, but trying to reach the site_url/api/identity API in the quality control environment yields "HTTP Error 500.0 - Internal Server Error".
I activated detailed logs in IIS and the error message in Event Viewer was "Could not load configuration. Exception message: Attribute 'processPath' is required."
The API's web.config file does have a process path:
<?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=".\PortalAPI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" forwardWindowsAuthToken="true"/>
</system.webServer>
</location>
</configuration>
Aditionally, the IIS error page shows something which I find strange. The request URL is correct, but the physical path is application_path\identity. "Identity" is an MVC controller, not a file.
The .NET Core 2.2 Windows Hosting Bundle is installed and the .NET path environment variable is set.
The application pool identity is an applicational user, and .NET CLR version is set to "No Managed Code".
The site has both Anonymous Authentication (for the front-end login page) and Windows Authentication enabled.
The thing is, I have hosted the applications in the exact same way in both the development environment and a clean Azure virtual machine, and they work in both, which makes me think this has to do with some setting in either IIS or the quality control machine itself.
Does anyone have any idea what the problem and/or possible solutions might be?
A missing configuration caused this error for me until I added it: environment variable ASPNETCORE_ENVIRONMENT
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\PortalAPI.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" >
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
You can put this in web.config, but it will get removed if you publish a new version of the web app from Visual Studio. To avoid that, put it in applicationHost.config instead (in the location corresponding to your site).
I am setting up a razor components .net core 3.0 preview in IIS.
From VS 2019 via IIS Express site works fine, but when I am hosting it with IIS itself - front-end logic is not working (no click responses, etc) How can I host razor components in IIS?
As I am seeing from IIS Express panel - it is hosted on 2 ports while my app is working. (Probably, client and server side)
According to MS the app is included with the ASP.NET Core app in the published output.
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=".\BlazorApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Looks like I am hosting only one side of razor components app, but should host both.
I'm getting an HTTP 502.5 error when trying to run my ASP.NET core 2.0 web app from IIS.
I've installed the .NET Core Windows Server Hosting Bundle and checked all my IIS settings as per this document https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?tabs=aspnetcore2x
The web.config looks like this.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\OscarWeb.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
The Windows event log produces the following errors.
It is IIS v6.2 running on Windows Server 2012 R2. The web application was built using ASP.NET Core 2.0.
When I run dotnet from the commandline as follows there are no errors:
dotnet oscarweb.dll
The first thing you have to do in this scenario is to create the logs folder if it is missing and check the stdout logs generated.
It can be several different things but from personal experience the most common issue i had was IIS not having enough permissions to run it. In IIS you can configure the Identity used in Advanced Settings. If it is using ApplicationPoolIdentity then change it to LocalSystem and see if it works. The logs in the stdtout file however will give you the answer.
The solution to this problem (in my case at least) was to reboot the web server. After installing the .NET Core Windows Server Hosting Bundle you need to reboot the server for them to be registered correctly.
Thanks to Chris Pratt (first comment underneath my question) for suggesting the answer :)
Not sure if your webconfig is complete. I believe aspnetcore tag needs to have the ASPNETCORE_ENVIRONMENT environment variable set as well.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\OscarWeb.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" >
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="YourRuntimeEnv" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
When I publish my .net Core 2.0 app to IIS I recieve a HTTP Error 502.5 Process Failure.
I have read the HOST ASP.NET Core... Several times without beeing able solving my problem.
I can start the app from cli "dotnet AppWebApi.dll" but i Can't access the app with the command "http://localhost:5000" Receive "WebPage cannot be found"
My best guess so far, is that the problem are related to hosting the .Net Core WebAPI as a SubWeb to an non .netCore WEB.
My web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<aspNetCore processPath="dotnet" arguments=".\AppWebAPI.dll" stdoutLogEnabled="true" stdoutLogFile=".\AppWebApi.log" forwardWindowsAuthToken="false" />
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
I Know similar questions has been asked before, but none of these has so far solved my problem, so I hope to get some new impulses.