简体   繁体   中英

IIS website with windows authentication does not run on local Windows 10 machine

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:\Users\XXX\Desktop\FirstProject\FirstProject\bin\Debug\netcoreapp3.1\FirstProject.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.

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)

  1. Use a valid domain that points to the IP of the server where your site is hosted.
  2. Add a host entry for the domain www.iiswebsite.com in 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

使用windows powershell打开项目所在的文件夹,然后写下这是Powershell。

dotnet run

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM