Visual Studio调试Web Application发生

2023-08-21  本文已影响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
net stop hns
net start hns
图1. 命令效果演示,注意询问是否继续的时候回答Y
上一篇 下一篇

猜你喜欢

热点阅读