Introduction:

About Platform:

Getting Started:

Download And Install DOTNET Core SDK And Runtime:

Go to the Microsft Dotnet Core downloads and download and install dotnet core SDK and Runtime.

SDK is the Software Development Kit, provides libraries to develop ASP.NET Core Applications and Runtime used by hosting servers.

Verify AspNetCoreModuleV2 Installation:

Now opens your local IIS server, goto Sites => Default Web Site select it. On the right side, pannel go to IIS => Modules select

Create ASP.NET Core MVC Application:

Creating And Configuring Web.config:

<?xml version="1.0" encoding="utf-8"?> <configuration> <!-- To customize the asp.net core module uncomment and edit the following section. For more info see https://go.microsoft.com/fwlink/?linkid=838655 --> <system.webServer> <handlers> <remove name="aspNetCore"/> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified"/> </handlers> <aspNetCore processPath="dotnet" arguments=".\bin\Debug

etcoreapp3.0\IISHostingTest.MVC.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" /> </system.webServer> </configuration>

'AspNetCoreModuleV2' specifying the server needs to target the Dotnet Core Runtime version 2.2 plus. So in the config section, we specified explicitly to run on 'AspNetCoreModuleV2'.

Now observe the 'aspNetCore' XML tag, its attributes are commands to startup the application. We need to pass 'arguments' value ".\bin\Debug

etcoreapp2.2\your_mvc_application_name.dll"(specifying our startup project dll location)

'stdoutLogEnabled' gives access to log the application level errors at the path provided in 'stdoutLogFile'.

Configure Application And Domain Binding:

SiteName => CoreApp (hosted application name in IIS Server)

PhysicalPath => "D:\exmples\AspCoreWithLocalIISSetup\LocalIISSetupSample\LocalIISSetupSample"(my sample Path)

HostName => "corewithlocaliis" (your site name, adding to the iis server)

Domain Binding In Host File:

Test Application:

Visual Studio Build Issue (Could Not Copy DLL Files):

Resolve Build Issue:

Target => Name => PreBuild means this tag gets run before building the project. Inside it, we are copying the "app_offline.htm" file from the wwwroot folder to the main folder. After copied the "app_offline.htm" file, IIS goes offline until the file deleted. Now build starts since IIS in offline mode build will get success.

Target => Name => PostBuild means this tag gets run after building the project. Inside it, we are deleting "app_offline.htm" from the root folder, so that the IIS server gets active.

If we carefully observe this only executes in debug mode nothing but development time. In release mode, there won't any effect of the tags in the image above.

Now build the project build issue fixed.

Debugging Using 'dotnet.exe' Command:

SetUp OverView:

Summary:

Asp.Net Core Sample application has been created, hosted in local IIS Server and debugging the project from Visual Studio. Discussed about pre and post build events helps in creating and deleting app_offline.htm file. Discussed Web.config configurations.





Dotnet core application can run by using hosting servers like1. IIS EXPRESS(built-in server in visual studio)2. KESTREL3. IIS SERVERand so on many other servers.The most commonly used server at development time is IIS EXPRESS. But we can do debugging the application by hosting it on Local IIS Server also. Using Local IIS helps to test any server-level configuration locally before going to the production server.The platform using for this sample below1. IIS Server 7 or above,2. Dotnet Core Framework 2.2v+3. Dotnet Core MVC4. Visual Studio 2017 or above (editor)Now we are going host a sample ASP.NET Core MVC application in our local IIS Server and then we are going debug our application in visual studio using Local IIS Server.displays, it says we successfully install Dotnet core 2.2 runtimes. If your not able to see that module once restart your pc and check.Now create asp.net core MVC application. Click here create MVC projectBy default in the dotnet core web application, we don't get web.config. Add web.config file as followsWeb.config:Now open the IIS server. Goto Sies => Add WebSite opens a popup as shown belowNow we need to register our domain like "corewithlocaliis" in the local host file. Now got to "C:\Windows\System32\drivers\etc" open local host file and addin that fileNow search your domain "corewithlocaliis" in browser your able to see the output as belownow we successfully configured our application, local IIS.Now while accessing the application from IIS, change code in visual studio and build project we get the following build issue.This issue because while DLL files are used by IIS, the visual studio tries to delete existing DLLs to recreate them on build command.In your application now add file name ain wwwroot folder. Now click on edit option onadd the following code.Now go to visual studio, select break pointer to debug code. Now click "Ctrl+Alt+p" opens Attach to process popup as belowSelect the donet.exe process, so the debugger gets activated. That's it we are good to debug our dotnet core application with our local IIS server.