Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need web.config in ASP .NET 5 wwwroot?

In ASP .NET 5, Configuration is changing drastically. We no longer have a web.config file. Instead, we can use JSON and other options, depending on how we set things up in our Startup class. Unlike web.config, such configuration typically doesn't go in wwwroot, and there is no danger that clients can gain access to it.

And yet, in the ASP .NET 5 project templates there's a web.config file in wwwroot with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
  </system.webServer>
</configuration>

It seems to me that this could be something that the hosting server is looking for at runtime, independently of the application configuration.

Can anyone shed some light on why this is needed, and how it works?

like image 864
Gigi Avatar asked Dec 27 '15 16:12

Gigi


People also ask

Does .NET 5 Use a web config?

In the past Web. config was used for both IIS configuration and application configuration and settings. But in asp.net 5 it is not used by the application at all, it is only used for IIS configuration.

What is the need for web config file?

A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).

Do we need web config for .NET core?

In order to set up the ASP.NET Core Module correctly, the web. config file must be present at the content root path (typically the app base path) of the deployed app.

Is web config necessary?

Yes, we can run an Asp.Net web application without web. config file but without in debugging mode. If we don't configure any settings in web. config file then it consider machine.


1 Answers

Web.config is strictly for IIS Configuration. It is not needed unless hosting in IIS. It is not used when you run the app from the command line.

In the past Web.config was used for both IIS configuration and application configuration and settings. But in asp.net 5 it is not used by the application at all, it is only used for IIS configuration.

This decoupling of the application from IIS is part of what makes cross platform possible.

like image 58
Joe Audette Avatar answered Oct 02 '22 02:10

Joe Audette