54

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?

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
toolshed
  • 1,919
  • 9
  • 38
  • 50

5 Answers5

57

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

Meet Shah
  • 750
  • 7
  • 5
  • 3
    Thank you. No need to search, it is there in the list when clicking on Web. Extra note: I used this simple web.config file in my project and when I published the whole solution using the File System method, I checked the 'auto-generated' version that it had created under the ...\publish\ directory and the new web.config file included the info I had added in the one I manually created PLUS the other CORE tags that it needed to generate. – Mario Levesque Mar 20 '19 at 13:10
23

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.

Freeubi
  • 336
  • 2
  • 11
18

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>
haiwuxing
  • 1,162
  • 10
  • 12
  • 2
    See [this](https://developercommunity.visualstudio.com/content/problem/26751/publish-aspnet-core-to-iis-with-windows-authentica.html) page if you need to set up Windows Authentication with IIS. Creating the web.config manually and adding the forwardWindowsAuthToken attribute was the only way I could get it to work. – James Toomey May 03 '17 at 17:43
  • 1
    This is the answer, and here is a link of an example: https://developercommunity.visualstudio.com/content/problem/26751/publish-aspnet-core-to-iis-with-windows-authentica.html – Antebios May 04 '18 at 21:30
6

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.

Mike Gledhill
  • 27,846
  • 7
  • 149
  • 159
  • 1
    I had same problem. In my case I just corrected the project paths in the file `%sln%\.vs\config\applicationhost.config` XML Path: `/configuration/system.applicationHost/sites/site/application/virtualDirectory` – smoq Jul 13 '18 at 08:45
-5

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/

Brijesh
  • 369
  • 2
  • 10