C# 无法连接到 ASP.Net 开发服务器问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/990033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:02:28  来源:igfitidea点击:

Unable to connect to ASP.Net Development Server issue

c#asp.netvisual-studio-2008debugging

提问by George2

I am debugging codeplex simple project. I am using

我正在调试codeplex 简单项目。我在用

  • VSTS 2008
  • C#
  • Windows Vista x86 Enterprise.
  • VSTS 2008
  • C#
  • Windows Vista x86 企业版。

I have not modified any code of this codeplex project, and just press F5 to run VideoPlayerWeb project.

我没有修改这个codeplex项目的任何代码,直接按F5运行VideoPlayerWeb项目。

The current issue I met with is error message --

我遇到的当前问题是错误消息-

Unable to connect to ASP.Net Development Server.

无法连接到 ASP.Net 开发服务器。

Here is my screen snapshots when clicking F5. Any ideas what is wrong?

这是我单击 F5 时的屏幕快照。任何想法有什么问题?

screenshot 1

截图 1

screenshot 2

截图 2

采纳答案by Beau

I had this problem with VS 2010, and it was as simple as terminating the "WebDev.WebServer40.EXE" process. Although the icon was no longer showing in the system tray, the process was still running.

我在 VS 2010 中遇到了这个问题,就像终止“WebDev.WebServer40.EXE”进程一样简单。虽然图标不再显示在系统托盘中,但该进程仍在运行。

回答by Marc

Could be a number of things...try these (check the last one first)...

可能有很多事情......试试这些(先检查最后一个)......

  • Disable IPv6
  • Make sure there isnt an edit in the hosts file for localhost
  • Check firewall/virus settings to allow connections to/from devenv.exe
  • If you can preview in the browser make sure the URL in the browser uses the same port number as the port number shown in the ASP.NET dev server taskbar icon.
  • Try setting a fixed, predefined port in project properties
  • 禁用 IPv6
  • 确保本地主机的主机文件中没有编辑
  • 检查防火墙/病毒设置以允许连接到/来自 devenv.exe
  • 如果您可以在浏览器中预览,请确保浏览器中的 URL 使用与 ASP.NET 开发服务器任务栏图标中显示的端口号相同的端口号。
  • 尝试在项目属性中设置固定的预定义端口

I got these from a couple of forums elsewhere, hopefully they can help. Good luck. Let us know what works and some more about your environment (firewall, anti virus etc) can help as well.

我从其他地方的几个论坛上得到了这些,希望它们可以提供帮助。祝你好运。让我们知道什么有效,更多关于您的环境(防火墙、防病毒等)也可以提供帮助。

回答by Andrew Siemer

That is very odd! I hate to suggest something as simple as restarting Visual Studio...but that is what sounds like the best first place to start. Also, check your project settings. As you said that you just downloaded this and tried to run it...perhaps the solution/project is not set up to use the Casini server that is shipped with Visual Studio?

这很奇怪!我讨厌建议像重新启动 Visual Studio 这样简单的事情……但这听起来是最好的开始。另外,请检查您的项目设置。正如您所说,您刚刚下载并尝试运行它...也许解决方案/项目未设置为使用 Visual Studio 附带的 Casini 服务器?

回答by Andrew Siemer

Here are the steps

以下是步骤

  1. 'Website' Menu in your visual studio ide.
  2. select 'Start Options'
  3. enable 'Use Custom Server' radio button.
  4. Enter any URL you desire similar to 'http://localhost:8010/MyApp'
  1. Visual Studio ide 中的“网站”菜单。
  2. 选择“开始选项”
  3. 启用“使用自定义服务器”单选按钮。
  4. 输入您想要的任何 URL,类似于“ http://localhost:8010/MyApp

Note1: you can use any port number not only '8010' but not designated port numbers like 8080(tcpip),25(smtp),21(ftp) etc.,

注意1:您可以使用任何端口号,不仅可以使用“8010”,而且不能使用指定的端口号,例如 8080(tcpip)、25(smtp)、21(ftp) 等,

Note2: you can use any name not only 'MyApp'

注意2:您可以使用任何名称,不仅是“MyApp”

This solution works for sure unless your WebDev.Webserver.exe is physically corrupted.

除非您的 WebDev.Webserver.exe 物理损坏,否则此解决方案肯定有效。

回答by brandon

Try commenting out the following line, if it exists, in your hosts file (%windir%\System32\drivers\etc\hosts):

尝试在您的主机文件 ( %windir%\System32\drivers\etc\hosts) 中注释掉以下行(如果存在):

::1     localhost

This worked for me using Visual Studio 2008 SP1 on Vista Ultimate x64 SP2.

这对我在 Vista Ultimate x64 SP2 上使用 Visual Studio 2008 SP1 有用。

回答by Christopher Galpin

My solution was to turn off Internet Connection Sharing on my wireless adapter, after which it immediately worked. I made no other change. I suspect ICS's DHCP server was interfering.

我的解决方案是关闭无线适配器上的 Internet 连接共享,之后它立即起作用。我没有做其他改变。我怀疑 ICS 的 DHCP 服务器正在干扰。

回答by Deepu Duvedi

Error 1) Unable to connect Asp.net development server ? Answer: No way find for that error

错误 1) 无法连接 Asp.net 开发服务器?答案:无法找到该错误

Try 1) Step 1: Select the “Tools->External Tools” menu option in VS or Visual Web Developer. This will allow you to configure and add new menu items to your Tools menu.

尝试 1) 步骤 1:在 VS 或 Visual Web Developer 中选择“工具->外部工具”菜单选项。这将允许您配置新菜单项并将其添加到“工具”菜单中。

Step 2: Click the “Add” button to add a new external tool menu item. Name it “WebServer on Port 8010” (or anything else you     want).

Step 3: For the “Command” textbox setting enter this value: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebD ev.WebServer.EXE     (note: this points to the 

web-server that VS usually automatically runs).

VS 通常自动运行的 Web 服务器)。

Step 4: For the “Arguments” textbox setting enter this value: /port:8010 /path:$(ProjectDir) (or any port you like)

Step 5: Select the “Use Output Window” checkbox (this will prevent the command-shell window from popping up.

Once you hit apply and ok you will now have a new menu item in your “Tools” menu called “WebServer on Port 8010”. You can now   select any web project in your solution 

and then choose this menu option to launch a web-server that has a root site on port 8010 (or whatever other port you want) for the project.

然后选择此菜单选项以启动一个 Web 服务器,该服务器在端口 8010(或您想要的任何其他端口)上为项目提供一个根站点。

You can then connect to this site in a browser by simply saying http://localhost:8010/. All root based references will work     fine.

Step 6: The last step is to configure your web project to automatically reference this web-server when you run or debug a site  instead of launching the built-in 

web-server itself. To-do this, select your web-project in the solution explorer, right click and select “property pages”. Select the “start options” setting on the left, and

网络服务器本身。为此,请在解决方案资源管理器中选择您的 Web 项目,右键单击并选择“属性页面”。选择左侧的“开始选项”设置,然后

under server change the radio button value from the default (which is use built-in webserver) to instead be “Use custom server”. Then set the Base URL value to be:

在服务器下将单选按钮值从默认值(使用内置网络服务器)改为“使用自定义服务器”。然后将 Base URL 值设置为:

http://localhost:8010/

http://本地主机:8010/

Obviously I don't know if this is the problem you had but definitely it is something similar, essentially the problem should be     that the same port used by your 

Development Server is not available because it is already used by another web server.

Development Server 不可用,因为它已被另一个 Web 服务器使用。

Try 2)

尝试 2)

Here are the steps

   1. 'Website' Menu in your visual studio ide.
   2. select 'Start Options'
   3. enable 'Use Custom Server' radio button.
   4. Enter any URL you desire similar to 'http://localhost:8010/MyApp'

Note1: you can use any port number not only '8010' but not designated port numbers like 8080(tcpip),25(smtp),21(ftp) etc.,

Note2: you can use any name not only 'MyApp'

This solution works for sure unless your WebDev.Webserver.exe is physically corrupted.

Both of not worked after that Windows repair option remain

在 Windows 修复选项仍然存在之后,两者都不起作用

回答by lafama

hi Just change the asp.netweb development server port from automatic to a specific port e.g 8010 That's what worked for me

嗨,只需将 asp.netweb 开发服务器端口从自动更改为特定端口,例如 8010 这对我有用

回答by Deepu Duvedi

1) not reflecting HttpContext in class file ?

1) 不在类文件中反映 HttpContext ?

Answer:-Most of the time when using this syntax in class file is not working we have to add reference then it work in class file

答:-大多数情况下,在类文件中使用此语法不起作用时,我们必须添加引用,然后才能在类文件中使用

example using system.web write this syntax in class file

使用 system.web 的示例在类文件中编写此语法

System.Web.HttpContext(HttpContext is not reflecting )

System.Web.HttpContext(HttpContext 不反映)

after that i add refrence system web than it reflect

之后我添加了参考系统网络而不是它反映的

回答by oscar

I got this problem a couple of times and done different things to fix it. When I got it this time all I did to stop getting "unable to connect to asp..." error, was rename the web app folder directory from xpCalto xpCal2.I also tried moving the web app directory to a different directory from C:users\<me>\desktop\to C:\users\<me>\desktop\new folderand it also worked.

我遇到了几次这个问题,并做了不同的事情来解决它。当我知道了这个时候,我所做的停止收到“无法连接到ASP ...”错误,是由重命名Web应用程序文件夹目录xpCalxpCal2.我也尝试过移动Web应用程序目录到不同的目录C:users\<me>\desktop\C:\users\<me>\desktop\new folder,它也工作。

I don't know why it worked, does VS 2010 keep information about web apps seperate from web apps folder.

我不知道它为什么有效,VS 2010 是否将有关 Web 应用程序的信息与 Web 应用程序文件夹分开。