Search code examples
c#asp.netsdk

Running dotnet Project.dll in Command Works, But Unable to Access URL


I created a new project and I'm trying to run the web app using PowerShell. The command runs successfully, but when I click on the URL, I encounter the following result. How can I resolve this issue?

enter image description here enter image description here

enter image description here There is the csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
  </ItemGroup>

  <ItemGroup>
    <None Update="dockerfile">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

Solution

  • First, make sure that there is a HomeController inside the project, and then check that there is an Index Action inside it. By default, when you do not enter an address, the /Home/Index path will be automatically opened, and if there is no file, you will get a 404 error.