inchirags@gmail.com Chirag's Asp.Net MVC Tutorial https://www.chirags.in
*********************************************************************************************
How to Publish and Deploy ASP.net MVC application in IIS
*********************************************************************************************
YouTube Video:
Here’s a step-by-step guide to publish and deploy an ASP.NET MVC application in IIS:
1. Prepare Your Environment
Install IIS:
Go to Control Panel > Programs > Turn Windows features on or off.
Select Internet Information Services (IIS) and ensure Web Management Tools and World Wide Web Services are checked.
Click OK to install.
Install .NET Hosting Bundle:
Download the latest ASP.NET Core Hosting Bundle or the appropriate version of the .NET framework for your application from the Microsoft website.
https://dotnet.microsoft.com/
Install it on the IIS server.
Check IIS Configuration:
Open IIS Manager (run inetmgr).
Ensure Application Pools have the required .NET CLR version for your app.
2. Publish the ASP.NET MVC Application
Open Your Project in Visual Studio:
Go to Build > Publish {YourAppName}.
Configure Publish Settings:
Choose Folder as the publish target.
Set a publish folder (e.g., C:\inetpub\wwwroot\YourApp).
Configure other settings like release mode (preferably Release) and click Finish.
Publish the Application:
Click Publish. The application files will be generated in the specified folder.
3. Configure IIS
Create a New Application Pool:
Open IIS Manager.
Under Application Pools, click Add Application Pool.
Name it (e.g., YourAppPool), set the .NET CLR version, and click OK.
Add a Website:
Right-click Sites in IIS Manager and select Add Website.
Enter:
Site name: YourApp
Physical path: The folder where you published the app (e.g., C:\inetpub\wwwroot\YourApp).
Binding: Set the hostname, IP, and port (default: 80).
Assign the new site to the Application Pool created earlier.
Click OK.
4. Configure Permissions
Set Folder Permissions:
Right-click the published folder (C:\inetpub\wwwroot\YourApp), select Properties.
Go to the Security tab, and ensure IIS_IUSRS has read and execute permissions.
Enable Static Content (if needed):
Go to Control Panel > Programs > Turn Windows features on or off.
Under IIS > World Wide Web Services > Common HTTP Features, ensure Static Content is enabled.
5. Database Configuration in web.config
<add name="CrudDbContext"
connectionString="Server=localhost;Database=CrudDb;User Id=sa;Password=admin@123;"
providerName="System.Data.SqlClient" />
</connectionStrings>
6. Test the Application
Restart IIS:
Run iisreset in the command prompt.
Access the Website:
Open a browser and navigate to http://localhost or the hostname/IP you configured.
7. Troubleshooting and Fine-Tuning
Enable Detailed Errors:
Go to the site in IIS Manager.
Select Error Pages, then Edit Feature Settings, and enable Detailed Errors.
Enable HTTPS (optional):
Bind an SSL certificate in Bindings for secure access.
Check Logs:
Check the Event Viewer or IIS logs (%SystemDrive%\inetpub\logs\LogFiles) for errors.
Firewall Settings:
Ensure the server firewall allows traffic on the application’s port (e.g., 80 for HTTP or 443 for HTTPS).
With these steps, your ASP.NET MVC application should be successfully deployed in IIS and accessible.
For any doubts and query, please write on YouTube video comments section.
Note : Flow the Process shown in video.
Please, Subscribe and like for more videos:
https://www.youtube.com/@chiragstutorial
Don't forget to, Follow, Like, Share &, Comment
Thanks & Regards,
Chitt Ranjan Mahto "Chirag"
_____________________________________________________________________
Note: All scripts used in this demo will be available in our website.
Link will be available in description.
#chirags
#chiragstutorial
chirags, chirags tutorial, chirags Asp.Net MVC tutorial