I have a simple ASP.NET Core application that I want to run with IIS and Windows Authentication.
I tested and ran it before (before adding Windows Authentication and IIS) and it worked fine: It just opens a browser page and shows a json with names and birthday dates.
Now, I followed exactly the official Microsoft Guide on how to Configure Windows Authentication in ASP.NET Core and after that worked, the Microsoft Guide on how to “host ASP.NET Core on Windows with IIS”. There I am stuck with the section
Browse the website
Because when I try to access http://www.iiswebsite.com/ (that’s the name of the website I added by working through the above mentioned Guide), Chrome says “This site can’t be reached”.
I went through my configurations three times and made sure everything is set up correctly/as mentioned in the guide (please note: I use Windows desktop operating systems)
Here is something I don’t understand: As suggested in the article about how to “Configure Windows Authentication in ASP.NET Core“, I added a web.config to the project’s root with the required configuration. Here it is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="C:UsersXXXDesktopFirstProjectFirstProjectbinDebugnetcoreapp3.1FirstProject.exe" arguments="" stdoutLogEnabled="false" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>
But the Microsoft Guide on how to “host ASP.NET Core on Windows with IIS” also suggests to add this line to web.config: <Project Sdk="Microsoft.NET.Sdk.Web">. When I do so, it complains “The Project element is not declared”. And when I publish, my website is still not found. Could this be the problem? Or am I doing something different totally wrong?
I hope the question is not too stupid. Normally I do Frontend stuff and ASP.NET Core, C#, IIS etc. is a whole new world to me.
I also searched StackOverflow with no success. Especially this question looked helpful, but sadly it didn’t work.
Additional information: The default IIS website on localhost runs successfully.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The domain www.iiswebsite.com is not a valid domain. It does not exist and Chrome does not know how to get to the domain.
Solution (2 options)
- Use a valid domain that points to the IP of the server where your site is hosted.
- Add a host entry for the domain
www.iiswebsite.comin your computer’s host file that points the the IP of the IIS server where your site is hosted
See this video that explains what DNS is: DNS Explained
For information on how to add a host entry see: How to modify your hosts file in Windows 10
Method 2
open your folder that project is in it using windows powershell, then write this is Powershell.
dotnet run
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0