Roadmap › IIS — Internet Information Services and Hosting .NET Applications › Module: Hosting .NET Applications
Lessons in this course (9)
4. Hosting ASP.NET Framework apps (Web Forms, MVC 5, Web API 2)
Intermediate★ Must knowLesson 4 of 9
- Install IIS with ASP.NET 4.x (
Web-Asp-Net45) — .NET Framework 4.8 is part of Windows Server. - App pool: .NET CLR v4.0, Integrated pipeline.
- Publish from Visual Studio (Folder or Web Deploy profile) with Release configuration —
Web.Release.configtransforms apply (connection strings,compilation debug="false",customErrors On). - Copy to the site folder;
bin\contains your DLLs;web.configat the root. - 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.