2

The application launches on Visual Studio using the IIS Express profile but I can't get it to run on the IIS local server.

When I try to host the application on the local IIS server, I cannot get it to work. I ran into a few problems while doing this like Error 500.19, and Error 401. Now, I have the directory listing displayed instead of the website.

Please Note - I am new to web programming and it's the first time I am trying to host using IIS server. Since the website runs fine on VS IIS Express, I am guessing, some of the IIS Settings that I am using could be incorrect.

Md Farid Uddin Kiron
  • 16,817
  • 3
  • 17
  • 43
Shilpa
  • 21
  • 1
  • `I am guessing, some of the IIS Settings that I am using could be incorrect`. Then please add that information to your question. – burnsi Feb 21 '23 at 23:52
  • There are quite a few configurations required before serving your application on IIS server. Sharing your config would help us to diagnose the main issue. – Talkhak1313 Feb 22 '23 at 00:59
  • Which config files should I share? Where can I find them? – Shilpa Feb 22 '23 at 01:06
  • "Now, I have the directory listing displayed instead of the website" looks rather terrible that you are on the wrong path very far. Roll back all your changes to the very beginning please, and run a report to see what might be wrong, https://docs.jexusmanager.com/tutorials/ancm-diagnostics.html – Lex Li Feb 22 '23 at 02:09
  • Have you installed `.NET Core Hosting Bundle` on your hosting machine? – Md Farid Uddin Kiron Feb 22 '23 at 05:15
  • Yes, that is installed. – Shilpa Feb 22 '23 at 05:50
  • Alright, follow the steps accordingly from the given answer. – Md Farid Uddin Kiron Feb 22 '23 at 06:02
  • @Shilpa You may refer to this post https://windowswebhostingreview.com/simple-way-to-host-your-asp-net-core-in-iis/. If you already install .net core hosting bundle, you may follow that tutorial. – Mark Spencer Mar 02 '23 at 04:14

1 Answers1

1

The application launches on Visual Studio using the IIS Express profile but I can't get it to run on the IIS local server.

Alright, first of all, Please check your control panel if you have enabled following features:

enter image description here

Note: As you are new, I would recommed you to enable all options in Internet information service to avoid further issues because if you miss anything which will lead you to another trouble that would be difficult to assist.

Check your asp.net core runtime on your hosting machine

dotnet --list-sdks

enter image description here

Install prerequisite files for hosting

dotnet-hosting-7.0.3-win

Note: If you don't have please download from here.

Check if the modules installed accordingly:

enter image description here

You should have following module:

enter image description here

Add New Site By Right Click:

enter image description here

enter image description here

Note: Make sure, you have right to access the path and the port you would be entered is unused or no other application is using.

Configure App Pool:

enter image description here

enter image description here

Note: For asp.net core app please select No managed Code from the dropdown.

Run The App:

enter image description here

Output:

enter image description here

Note: If you would like to know more details on how to publish ASP.NET Core app to IIS you could check our official document here.

Md Farid Uddin Kiron
  • 16,817
  • 3
  • 17
  • 43
  • Thanks for the detailed steps. After following the above steps, I now have HTTP Error 500.30. I tried the following: Run the application from command prompt using dotnet command. It runs fine. The event logger has the following error: System.InvalidOperationException: The Negotiate Authentication handler cannot be used on a server that directly supports Windows Authentication. Enable Windows Authentication for the server and the Negotiate Authentication handler will defer to it. – Shilpa Feb 22 '23 at 23:27
  • I turned on the Windows authentication and Anonymous authentication in the IIS server. The site is now not reachable. Not sure what's going on. No logs in the event logger this time. – Shilpa Feb 22 '23 at 23:49
  • Remove all of your previous configuration and then follow the steps accordingly what I showed, no more additional changes at the begining. Once it works as expected then start your customization. As I said earlier, for any additional settings if anything goes wrong it would be harder for you to fix. Also use a port other than 80. For instance, you can use port 8001. – Md Farid Uddin Kiron Feb 23 '23 at 00:55