Setting IIS Settings in Web.config using ASP.NET MVC 6

1.7k views Asked by At

An ASP.NET MVC 6 project does not come with a Web.config file by default. However, if you want to use IIS, then you need to add one under the wwwroot folder. There seems to be very little information about running MVC 6 sites under IIS (Which 99% of people would want to do).

  1. How do you go about creating a Debug/Release or in the new world Development/Staging/Production version of the Web.config file.
  2. The appSettings and connectionStrings are now deprecated in favour of the new Configuration model.
  3. Can we still use the settings under system.web like authentication, caching, compilation, customErrors, httpCookies, sessionState and trace?
  4. What about the runtime assemblyBindings's? Do we still need these?
  5. What about HTTP Handlers? In MVC 5, we had to remove the Trace handler in the release build or we got a 500 Internal Server error when navigating to /Trace.axd, instead of 404 Not Found. Do we still need to remove them?
1

There are 1 answers

3
Matt DeKrey On BEST ANSWER

They don't really have the documentation for much of ASP.NET 5 built up, but the instructions for publishing to IIS are fairly clear.

This process generates a very tiny web.config for you. For example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="bootstrapper-version" value="1.0.0-beta6-11895" />
    <add key="runtime-path" value="..\approot\runtimes" />
    <add key="dnx-version" value="1.0.0-beta6-12005" />
    <add key="dnx-clr" value="clr" />
    <add key="dnx-app-base" value="..\approot\src\Sample" />
  </appSettings>
</configuration>

Other than that, it looks like the system.webServer section will be respected by IIS, including compression and caching.