razor webapp 无法再在我的计算机上启动。
构建命令
dotnet build
按预期工作,但 dotnet run
在第一次警告后卡住了。
C:\dev\mywebapp>dotnet run
Building...
C:\dev\mywebapp\Pages\Admin\Orders\TraderOrderList.cshtml.cs(101,17):
warning CS0219: The variable 'orderId' is assigned but its value is
never used [C:\dev\mywebapp\MyWebApp.csproj]
C:\dev\mywebapp\Pages\Index.cshtml.cs(23,24):
warning CS0414: The field 'IndexModel._currentAd' is assigned but its value is
never used [C:\dev\mywebapp\MyWebApp.csproj]
--- after here it is stuck no more output and i stopped it after about 3 minutes
c:\dev\webtemp>dotnet new webapp -o HelloWebApp
c:\dev\webtemp\HelloWebApp>dotnet run
运行它。所以这按预期工作。我在stackoverflow上搜索了其他问题,但没有遇到同样的问题。
为简洁起见,以下某些路径已被替换
所使用的名字 | 路径 |
---|---|
|
|
|
|
|
|
运行
dotnet --info
返回
c:\dev\webtemp\HelloWebApp>dotnet --info
.NET SDK: Version: 7.0.100 Commit: e12b7af219
Runtime Environment:
OS Name: Windows OS Version: 10.0.19042
OS Platform: Windows RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100\
Host: Version: 7.0.0 Architecture: x64 Commit: d099f075e4
.NET SDKs installed:
3.1.120 [C:\Program Files\dotnet\sdk] 3.1.426 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.113 [C:\Program Files\dotnet\sdk]
7.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.20 [<path-to-AspNetCore.App>]
Microsoft.AspNetCore.App 3.1.32 [<path-to-AspNetCore.App>]
Microsoft.AspNetCore.App 5.0.17 [<path-to-AspNetCore.App>]
Microsoft.AspNetCore.App 6.0.13 [<path-to-AspNetCore.App>]
Microsoft.AspNetCore.App 7.0.0 [<path-to-AspNetCore.App>]
Microsoft.NETCore.App 3.1.20 [<path-shared-NETCore>]
Microsoft.NETCore.App 3.1.32 [<path-shared-NETCore>]
Microsoft.NETCore.App 5.0.17 [<path-shared-NETCore>]
Microsoft.NETCore.App 6.0.13 [<path-shared-NETCore>]
Microsoft.NETCore.App 7.0.0 [<path-shared-NETCore>]
Microsoft.WindowsDesktop.App 3.1.20 [<path-shared-WindowsDesktop>]
Microsoft.WindowsDesktop.App 3.1.32 [<path-shared-WindowsDesktop>]
Microsoft.WindowsDesktop.App 5.0.17 [<path-shared-WindowsDesktop>]
Microsoft.WindowsDesktop.App 6.0.13 [<path-shared-WindowsDesktop>]
Microsoft.WindowsDesktop.App 7.0.0 [<path-shared-WindowsDesktop>]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables: Not set
global.json file: Not found
我确实更改了分支,并且
dotnet run
到达了本地主机启动的部分。
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7178 info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5057 info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\dev\mywebapp\
但它返回http 404
404 未找到
服务器找不到所请求的资源。 ...
服务器也可以将此响应而不是 403 Forbidden 发送至 对未经授权的客户端隐藏资源的存在。
我尝试了几个不同的网址,但每个剃刀页面都失败了(404)。只有wwwroot下的静态html页面有效(200)
路径 | 网址 | 结果 |
---|---|---|
|
|
200 |
|
|
404 |
如上所述 |
|
404 |
如上所述 |
|
404 |
如上所述 |
|
404 |
这里可以看到devtools的截图
前几天我遇到了类似的问题。
就我而言,我使用 NLog 进行日志记录。我已经输入了所有必要的代码和配置,但忘记在我的项目中创建
nlog.config
文件。缺少 nlog.config
文件导致应用程序挂起。