美文网首页
Visual Studio调试Web Application发生

Visual Studio调试Web Application发生

作者: 达哥傻乐 | 来源:发表于2023-08-21 14:04 被阅读0次

在用VS调试Web Application的时候发生错误10013如下,大意是绑定本地的网络端口失败,比如下面错误示例中的5210端口。

Unhandled exception. System.IO.IOException: Failed to bind to address http://localhost:5210.
---> System.AggregateException: One or more errors occurred. (An attempt was made to access a socket in a way forbidden by its access permissions.) (An attempt was made to access a socket in a way forbidden by its access permissions.)
---> System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.

出现这种情况,如果反复启动Web Application该错误依然重复出现,同时可以发现这个端口多半是随机变化的,就基本排除了网络端口被占用的可能性。

  • 如果不排除网络端口被占用的可能性,那么先找出占用该网络端口的进程,然后结束这个进程即可,步骤如下:
  1. 找出占用端口的进程。在命令行中输入 netstat -ano | findstr :你的端口号
  2. 结束占用端口的进程。在命令行中输入 taskkill /PID 进程ID /F
  • 如果排除了网络端口被占用的可能性,那么极可能是主机网络服务工作不正常导致的,在具备管理员权限的PowerShell或者命令提示符中使用下面的命令解决:
net stop hns
net start hns
图1. 命令效果演示,注意询问是否继续的时候回答Y

相关文章

网友评论

      本文标题:Visual Studio调试Web Application发生

      本文链接:https://www.haomeiwen.com/subject/jttymdtx.html