Lessons in this course (9)

4. Hosting ASP.NET Framework apps (Web Forms, MVC 5, Web API 2)

Intermediate★ Must knowLesson 4 of 9
  1. Install IIS with ASP.NET 4.x (Web-Asp-Net45) — .NET Framework 4.8 is part of Windows Server.
  2. App pool: .NET CLR v4.0, Integrated pipeline.
  3. Publish from Visual Studio (Folder or Web Deploy profile) with Release configuration — Web.Release.config transforms apply (connection strings, compilation debug="false", customErrors On).
  4. Copy to the site folder; bin\ contains your DLLs; web.config at the root.
  5. Grant the pool identity read access; write access only to folders that need it (uploads, App_Data, logs).
xml
<!-- web.config essentials for production -->
<system.web>
  <compilation debug="false" targetFramework="4.8" />
  <customErrors mode="RemoteOnly" defaultRedirect="~/Error" />
  <httpRuntime targetFramework="4.8" enableVersionHeader="false" maxRequestLength="10240" />
  <sessionState mode="SQLServer" sqlConnectionString="..." />          <!-- web farm -->
</system.web>
<system.webServer>
  <httpErrors errorMode="DetailedLocalOnly" />
  <security><requestFiltering removeServerHeader="true"><requestLimits maxAllowedContentLength="10485760" /></requestFiltering></security>
  <staticContent><clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" /></staticContent>
</system.webServer>

system.web = ASP.NET settings; system.webServer = IIS settings (integrated mode). Changing web.config or bin\ contents restarts the application domain.