c# - 红隼无法启动

标签 c# kestrel-http-server

使用 .UseKestrel() 指定要绑定(bind)的端口时我收到下面列出的错误..但是如果我删除红隼选项,如果我从浏览器检查 API,一切都会正常工作。

我已尝试绑定(bind)到我的应用程序默认使用的端口,但未选择任何端口,我已尝试检查 netstat主动避免任何正在使用的端口。除了完全删除选项外,没有任何效果。这不会在我的 Mac 或另一台 Windows 10 机器上复制。此设备是 Windows 10。

.UseKestrel(options =>
{
    options.Listen(IPAddress.Loopback, 50470);
    options.Listen(IPAddress.Any, 80);
})

: Microsoft.AspNetCore.Server.Kestrel[0]
Overriding address(es) 'http://localhost:50470/'. Binding to endpoints defined 
in UseKestrel() instead.
crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.Net.Sockets.SocketException (10013): An attempt was made to access a 
socket in a way forbidden by its access permissions
at 
System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException
(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress 
socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport.
BindAsync() at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer. 
<>c__DisplayClass21_01.<<StartAsync>g__OnBind|0>d.MoveNext() ` 

最佳答案

还可以在这里查看 Darkthread 的答案:https://superuser.com/questions/1486417/unable-to-start-kestrel-getting-an-attempt-was-made-to-access-a-socket-in-a-way

我们发现一个我们使用了很长时间的端口已经无法访问了,因为它已经被 Windows 保留了!您可能希望使用以下命令检查保留端口:netsh interface ipv4 show excludedportrange protocol=tcp

关于c# - 红隼无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54671199/

相关文章:

c# - : Static class as Generic-Parameter 的替代方案

c# - 为属性赋值时在构造函数中调用虚拟成员

c# - 在Asp.Net Core v3.1中增加上传文件的大小

apache - Blazor/Kestrel/Apache : How to configure properly?

c# - .NET Core 1.1 项目启动时 Microsoft.AspNetCore.Server.Kestrel 中的 TypeLoadException

c# - 查询在 HeidiSQL 中有效,但在 C# 中失败

c# - 在触发对撞机中使用 IsTouching()

c# - 将小型 C# 校验和程序转换为 Java

c# - 与 IIS 相比,Kestrel 的性能较慢

c# - 从 Web API 提供文件和路由