I am trying to get our existing asp.NET core mvc app to run in an azure app service. Deployment works fine and all files i would expect are on the server.
Sadly, after trying to visit the url I am greeted by the message "You do not have permission to view this directory or page." which is the Statuscode 403.
The Log gives some more insight:
<div id="content"><div class="content-container"><h3>HTTP Error 403.14 - Forbidden</h3><h4>The Web server is configured to not list the contents of this directory.</h4></div><div class="content-container"><fieldset><h4>Most likely causes:</h4><ul> <li>A default document is not configured for the requested URL, and directory browsing is not enabled on the server.</li> </ul></fieldset></div><div class="content-container"><fieldset><h4>Things you can try:</h4><ul> <li>If you do not want to enable directory browsing, ensure that a default document is configured and that the file exists.</li> <li> Enable directory browsing using IIS Manager. <ol> <li>Open IIS Manager.</li> <li>In the Features view, double-click Directory Browsing.</li> <li>On the Directory Browsing page, in the Actions pane, click Enable.</li> </ol> </li> <li>Verify that the configuration/system.webServer/directoryBrowse#enabled attribute is set to true in the site or application configuration file.</li>
It seems like I am supposed to use some sort of landing page like index.html but that is not present for the given mvc Project.
I couldn't find any documentation for this configuration either. Even the youtube videos showcasing how easy it is to host a mvc app don't have to do any further configuration. (for example this one: watch)
I would be happy if anyone could tell me where I went wrong.
Thanks in advance,
Joshua
I have deployed a .NET Core MVC application over Azure App Service via Visual Studio and it worked. So, I notice that on this process, VS creates a web.config file. Once I remove it from App Service via Kudu, the application stopped.
So, the solution is to create a web.config file in the wwwroot folder on App Service environment. The content is like below:
<?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=".\My.Main.Project.dll"
stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout"
hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
For the record, the application was created on .NET Core 3.1.
Related
I am trying to deploy my Blazor WA to my local IIS, I have already deployed other .net core 3.1 API to another site locally. I have also successfully deployed the Blazor App to Azure Blob storage static website. From VS 2019 I click publish and it successfully publishes the file to the selected folder.
when I navigate to the url http://localhost:6989 I get 404 not found. I have followed the steps required from multiple locations
https://hostadvice.com/how-to/how-to-deploy-a-blazor-application-on-iis/
Here are the things I've changes in the site. not much has changed:
Web.cong settings:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
#LexLi Thanks for the comment. I used your comment to discover why my web.config was wrong. I had Some wrong versions of the assembles and I guess it wasn't acting nicely. I cleaned up the project and make sure I was using v3.2 and the web.config was generated properly
We’re building a web app (aspcore 3.0) published in app service.
This problem is that the mine type (json) is not recognized.
How to fix it ?
Thank you
It sounds like you were using Azure App Service on Windows to deploy your ASP.NET Core 3.0 application, but IIS on Azure WebApp can not set the response header Content-Type for JSON.
The reason is IIS on Azure WebApp default does not support static JSON file. To fix it, you need to change the web.config file to add the feature, as below.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
As reference, there is the other SO thread Getting "404 not found" on doing a GET on local file in Azure web app got the similar issue as yours and I answered it, please refer to it.
Problem
When hosting an Asp.Net Core 2.0 or 2.1 Web Application behind IIS with Windows Authentication set to true, and Anonymous Authentication set to false, the User.Identity.Name property is null and User.Identity.IsAuthenticated is false.
According to the documentation here, Windows Authentication should just work in Asp.Net Core 2.x when hosting with IIS.
Background
I'm in the process of migrating an Asp.Net 4.x MVC application over to Asp.Net Core following the Migrate from ASP.NET MVC to ASP.NET Core MVC guide.
I'm testing the site on a server that is currently hosting Asp.Net 4.x MVC applications that use Windows Authentication without issue. The Identity of the Windows user is available as expected.
After completing the migration guide and fixing all build issues, I've created a "Local IIS" profile under "Debug" in the web project properties, setting the "Launch" option to "IIS". I've ticked only "Enable Windows Authentication" and then browsed to the website. Despite being logged in with valid domain credentials, User.Identity.Name is still null.
I installed the .Net Core 2.1 SDK before starting the migration process and have previously installed the .Net Core 1.0.1 SDK Preview. The server is running Windows 2008 R2 with IIS 7.
What I've Tried
In order to ensure I hadn't introduced this problem during the migration process I created a new ASP.NET Core Web Applications, using the MVC template and targeting .NET Framework 4.7.2. I configured "Windows Authentication" when choosing the template. After confirming that Windows Authentication worked when using IIS Express, I configured Local IIS as above. When browsed to under IIS, the top right of the navigation bar shows "Hello, !". I tried this with templates from Asp.Net Core SDK 2.0 and 2.1.
I've followed various guides and Stackoverflow answers all relating to configuring Windows Authentication within the Asp.Net Core application itself. Results have been either no change, or continuous login prompts that never accept a valid username and password. It appears these solutions may be written for older versions of the framework or scenarios where the developer is attempting to combine multiple authentication methods.
Cause
The server has an outdated .Net Core 2.0 IIS Module installed that does not forward windows authentication details by default. This problem is described here: .Net Core 2.0 Project With Windows Authentication Fail When Published to IIS. Installing the latest .Net Core 2.0 Runtime should fix this.
This can be verified this by running the following in PowerShell:
(Get-Item $env:SystemDrive\Windows\System32\inetsrv\aspnetcore.dll).VersionInfo
This gives the following output:
ProductVersion FileVersion FileName
-------------- ----------- --------
7.1.1967.0 7.1.1967.0 C:\Windows\System32\inetsrv\aspnetcore.dll
The server requires version 7.1.1972.0 or higher.
Solution 1 - Project Fix
In the web.config generated by Visual Studio 2017 when configuring Local IIS, add forwardWindowsAuthToken="true" as an attribute to the <aspNetCore> element:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="bin\IISSupport\VSIISExeLauncher.exe" arguments="-argFile IISExeLauncherArgs.txt" stdoutLogEnabled="false" forwardWindowsAuthToken="true" />
</system.webServer>
</location>
<system.web>
<authentication mode="Windows" />
</system.web>
</configuration>
Solution 2 - System-Wide Fix
Download and install the latest .Net Core Runtime from the .Net downloads page. The Runtime includes the Windows Hosting Bundle and required IIS module. If the SDK is already installed this will include the Runtime, however, the Runtime may still need to be installed again by itself to fix this issue (choose the repair option).
Is there a way to set requestTimeout from C# instead of needing to set requestTimeout in the web.config?
asp.net core 2.0 hosted in IIS
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore requestTimeout="00:00:04" processPath="dotnet" arguments=".\Foo.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Not like this
No, there is no way to do that as you described. But according to the documentation you can just add web.config to your project and specify this (and other) setting value:
If a web.config file isn't present in the project, the file is created
with the correct processPath and arguments to configure the ASP.NET
Core Module and moved to published output.
If a web.config file is present in the project, the file is
transformed with the correct processPath and arguments to configure
the ASP.NET Core Module and moved to published output. The
transformation doesn't modify IIS configuration settings in the file.
The web.config file may provide additional IIS configuration settings
that control active IIS modules. For information on IIS modules that
are capable of processing requests with ASP.NET Core apps, see the IIS
modules topic.
To prevent the Web SDK from transforming the web.config file, use the
IsTransformWebConfigDisabled property in the project file.
I have recently migrated from Azure Cloud Service to Azure Web App. Earlier I use to Disable the rapidFailProtection from my Webrole class. After the migration to Web App, I have remove the webrole class and added the code of rapidFail in the Application startup routine of the global.asax file. But it gave an error:
role discovery data is unavailable
at the following line:
Dim mainSite = serverManager.Sites(RoleEnvironment.CurrentRoleInstance.Id + "_Web")
How can I achieve the same functionality for my Azure Web App?
How can I achieve the same functionality for my Azure Web App?
As far as I know, the rapidFailProtection is a application pool setting which you could set it in the ApplicationHost.config file in app service.
So if you want to set the rapidFailProtection to false in the azure web app, I suggest you could try to use XML Document Transformation (XDT) declarations to transform the ApplicationHost.config file in your web app in Azure App Service.
I suggest you could try below steps to add the XDT file to your web app to change the ApplicationHost.config settings.
1.Access the KUDU console.Find the Advanced Tools in DEVELOPMENT TOOLS click go.
2.Click dubug console's cmd.
3.Locate the D:\home\site and add below xdt file.
Notice: Change the name as your web app service name
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.applicationHost>
<applicationPools>
<add name="testforapppool" xdt:Locator="Match(name)">
<failure rapidFailProtection="false" xdt:Transform="InsertBefore(/configuration/system.applicationHost/applicationPools/add[(#name='testforapppool')]/*[1])" />
</add>
<add name="~1testforapppool" xdt:Locator="Match(name)">
<failure rapidFailProtection="false" xdt:Transform="InsertBefore(/configuration/system.applicationHost/applicationPools/add[(#name='~1testforapppool')]/*[1])" />
</add>
</applicationPools>
</system.applicationHost>
</configuration>
Image:
Besides, you could also install Site Extension called IIS Manager which lets you very easily create XDT files simply by editing your applicationhost.config.
More details, you could refer to this article:
Azure App Service web app advanced config and extensions
Xdt transform samples