Publish the project to the IIS server through Visual Studio

Because it hasn’t been long since I got into ASP.NET/C#,You have to explore many basic things on your own,Sometimes things that are taken for granted by others,I might spend a lot of time researching。Since time has been spent,I want to record the process,Let people like me save some time。

This time it is being completed QRCode generator API Later,I have no idea how to turn the program into content that IIS can eat.,Although I did it once half a year ago,But my head is already empty,Oh。

"Build and Release"
First change the "Build Configuration" of the project to “Realese”。to create results suitable for deployment in a formal environment。
(Relative to Realese,The result of Debug configuration,Debug information will be included,Suitable for development and testing。)


Right click on the project,Select "Build"。


After the construction is completed,Same as right-clicking on the project,Select "Publish"。to prepare the file structure for use by the web server。


Since I published it by manually copying the file to IIS,Therefore, the published "Target" will select "Folder"。


Finally, select "Publish",The program to be copied to IIS will be generated in the "Target Path"。

"IIS Deployment"
In the general case,Right-click "Site" to add a new site,and point to the folder where the file you just published is stored。


But this time I want to use the existing platform,Add a new subsite (dad.abc.com.tw/son/) concept,Therefore, right-click on the existing site,Select "Add Application",Then just point to the folder where the file just published is stored.。


I've been stuck on the "Application" side for a long time.,I originally thought I was going to add a "virtual directory",But the website has been unable to run,Later, I finally relied on ChatGPT to rescue me. (Full of gratitude)。"Virtual directory" will use parent site resources,More suitable for static images、css files, etc.,If you use it to put an ASP website,There may be some troublesome relative paths to deal with。
"Application" is equivalent to an independent website,Resources are independent,Only the domain name part is hung under the parent layer. (dad.abc.com.tw/son/),So after I converted to app,The website just works,The program does not need to adjust for relative path conditions at all.。


In addition,If you are developing with ASP.NET Core,Since ASP.NET Core does not directly depend on the .NET CLR in IIS (Common Language Runtime),Instead, it uses its own Kestrel server to handle requests,Then use IIS as a reverse proxy,Therefore,For ASP.NET Core,Application clusters are typically set to "No Controlled Codes",Not starting the .NET CLR,Can save resources。

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.