web.config missing when creating ASP.NET Core Web App in VS 2017 RC?

asp.net CoreVisual Studio-2017

asp.net Core Problem Overview


I've noted that when creating a new ASP.NET Core Web App in Visual Studio 2017 RC, a web.config file is not created. My understanding was that this file contains important code to facilitate IIS integration, something that I am interested in, as I would like to run this application on IIS.

Is this a bug, or have I missed a step in the process?

asp.net Core Solutions


Solution 1 - asp.net Core

In Visual Studio 2017, right click in Project in Solution Explorer -> Add -> New Item -> Search for "config" -> Add Web Configuration File. This will add web.config in your project with default stuff.

enter image description here

Solution 2 - asp.net Core

For Asp.Net Core 2.0, and you still need to have web.config you can add a Web configuration item template. You can use that like change the max file upload limit etc.

The web.config file is generated when you are publishing the project.

Solution 3 - asp.net Core

In ASP.NET Core 1.1 Web project that created by Visual Studio 2017, there is no more web.config file by default. If you need that file, you can create that file by yourself. For example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
  </system.webServer>
</configuration>

Solution 4 - asp.net Core

This isn't a direct answer to your question, but I want to post this solution, as it is related.

Today, I found that VS2017 refused to start my web app as it said it couldn't find a web.config file.

The error message showed the path where it was searching for the web.config in, but it was a folder that had never existed on my laptop (I'd been sent the code from an external company). Even worse, our project didn't even contain a web.config file, so the error made no sense !!

I spent ages trying to get around this issue, reported by IIS Express with VS2017, and the solution was ridiculous:

I just had to increment the port number which my code was running under.

That's it.

Is this a bug with IIS/VS2017 ? I don't know. But it wasted a lot of my time this morning. And renaming the following folder out of the way, as suggested by other StackOverflow articles, didn't help:

C:\Windows\System32\inetsrv\config

Again, apologies - this isn't a direct answer to the question, but I'm sure I won't be the only person to stumble on this webpage, after receiving this bizarre "Can't find web.config" error, so I think it is useful to document here.

Solution 5 - asp.net Core

In ASP.Net core we do not have web.config rather we have app.config file. In ASP.Net Core configuration has been changed a lot, now packages are managed via Package.json file.

In case you need to store some app related configuration then you can use appsetting.json file.

refer: https://zimmergren.net/using-appsettings-json-instead-of-web-config-in-net-core-projects/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontoolshedView Question on Stackoverflow
Solution 1 - asp.net CoreMeet ShahView Answer on Stackoverflow
Solution 2 - asp.net CoreFreeubiView Answer on Stackoverflow
Solution 3 - asp.net CorehaiwuxingView Answer on Stackoverflow
Solution 4 - asp.net CoreMike GledhillView Answer on Stackoverflow
Solution 5 - asp.net CoreBrijeshView Answer on Stackoverflow