C# IIS Express 停止 Web 应用程序后立即关闭正在运行的站点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14376154/
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-10 11:38:49  来源:igfitidea点击:

IIS Express Immediately shutting-down running site after stopping web application

c#asp.netvisual-studiovisual-studio-2012iis-express

提问by saber

I'm using visual studio 2012 in the first days when I want to stop application in IDE, application was still running on IIS Express, I could browse and work with running application, but now I can't. IIS Immediately shutting-down application if I press stop button. Since I remember I didn't make any changes in setting. How should I do that running same as first days.

当我想在 IDE 中停止应用程序时,我正在使用 Visual Studio 2012,应用程序仍在 IIS Express 上运行,我可以浏览和使用正在运行的应用程序,但现在我不能。如果我按下停止按钮,IIS 会立即关闭应用程序。因为我记得我没有对设置进行任何更改。我应该如何像第一天一样运行。

采纳答案by Abhi

I recently faced a similar situation when suddenly my IIS Express stopped right after I stopped debugging. This happened after I turned on "Enable Edit and Continue". So if you disable this you will see that IIS Express stays running even after debugging is stopped.

我最近遇到了类似的情况,在我停止调试后突然我的 IIS Express 停止了。这是在我打开“启用编辑并继续”之后发生的。因此,如果您禁用此功能,您将看到 IIS Express 即使在调试停止后仍保持运行。

Right click your project > click Properties > select the 'Web' tab on the left > uncheck the Enable Edit and Continuecheckbox.

右键单击您的项目 > 单击属性 > 选择左侧的“Web”选项卡 > 取消选中Enable Edit and Continue复选框。

回答by jessehouwing

Instead of hitting the (X) STOPbutton, you can use the Detach allmenu item in the Debug menu. The major difference is that the stop button will terminate any process that is currently being debugged, while Detach All will disconnect the debugger from the processes, but will not terminate them.

(X) STOP您可以使用Detach all“调试”菜单中的菜单项,而不是点击按钮。主要区别在于停止按钮将终止当前正在调试的任何进程,而 Detach All 将断开调试器与进程的连接,但不会终止它们。

The normal IIS worker process would also be terminated, but since it used to be running as a service, it will also automatically start up again and thus you could continue to use it without having to restart the process through |> Debugor |> Start without debugging.

正常的 IIS 工作进程也会被终止,但由于它曾经作为服务运行,它也会自动再次启动,因此您可以继续使用它,而无需通过|> Debug或重新启动进程|> Start without debugging

Screenshot for Reference

参考截图

Adding 'Edit and Continue' button to debugging toolbar.

向调试工具栏添加“编辑并继续”按钮。

回答by giammin

In VS2010 and VS2012, the edit and continue option is disabled by default when creating a new web application project. In VS2013 it is turned on by default.

在 VS2010 和 VS2012 中,在创建新的 Web 应用程序项目时,编辑并继续选项默认处于禁用状态。在 VS2013 中它默认是打开的。

You can find this option on the Web tab in the web project's properties window.

您可以在 Web 项目属性窗口的 Web 选项卡上找到此选项。

edit and continue option vs2013

编辑并继续选项 vs2013

With “Enable Edit and Continue” on, the VS debugger starts your web application in IIS Express. When you stop debugging, IIS Express is closed too. With this behavior, you will see the IIS Express system tray shows up during debugging and gone after debugging. This behavior is the same as in VS2012 when the Enable Edit and Continue option is turned on.

启用“启用编辑并继续”后,VS 调试器将在 IIS Express 中启动您的 Web 应用程序。当您停止调试时,IIS Express 也会关闭。通过这种行为,您将看到 IIS Express 系统托盘在调试期间出现并在调试后消失。当启用编辑并继续选项打开时,此行为与 VS2012 中的相同。

If you don't need "Edit and Continue" functionalityduring development and would like IIS Express to stay after a debugging session, you can simply turn the Enable Edit and Continue option off.

如果您在开发过程中不需要“编辑并继续”功能,并且希望 IIS Express 在调试会话后保持不变,您只需关闭“启用编辑并继续”选项即可

If you want to use "Edit and Continue" or you are developing an Asp.net 5 site(ASP.NET 5 projects don't have an Edit and Continue checkbox in project properties) you have to use the "Detech all" commandto stop debugging.

F你想使用“编辑并继续”,或者你正在开发一个Asp.net 5个网站(ASP.NET 5个项目没有一个编辑并继续在项目属性复选框),您必须使用“Detech all”命令停止调试。

The debugger will detach from the iis process without closing it.

调试器将脱离 iis 进程而不关闭它。

Clearly "Edit and Continue" feature will not work until you start debugging again.

显然,在您再次开始调试之前,“编辑并继续”功能将不起作用。

enter image description here

在此处输入图片说明

回答by tocqueville

It seems like since the release of Visual Studio 2015 Update 2 the accepted solution no longer works.

似乎自 Visual Studio 2015 Update 2 发布以来,公认的解决方案不再有效。

The easiest solution I've found so far is to start the project by selecting "Start Without Debugging" from the Debugmenu.

到目前为止,我找到的最简单的解决方案是通过从Debug菜单中选择“ Start without Debugging”来启动项目。

回答by b_levitt

This is probably best categorized as another workaround, but it works for me.

这可能最好归类为另一种解决方法,但它对我有用。

I generally start the project for the first time with the "View in Browser" context menu (or CTRL-Shift-W).

我通常第一次使用“在浏览器中查看”上下文菜单(或 CTRL-Shift-W)启动项目。

From then on, anything that requires debugging, I usually attach to the new existing iisexpress process. While mousing thru context menues would make this a non-starter, it is nearly as quick as F5 with the following keystrokes:

从那时起,任何需要调试的东西,我通常会附加到新的现有 iisexpress 进程。虽然鼠标通过上下文菜单会使其成为一个非启动器,但使用以下按键几乎与 F5 一样快:

  • Shift-F6 to build the current project or Ctrl-Shift-B to build the entire solution (this is only required if you have made changes but I thought I should mention it since F5 already does this).
  • Ctrl-Alt-P opens the attach to process dialog

  • typing "iis" will then bring you down to the iisexpress process

  • hit enter and you're attached
  • Shift-F6 构建当前项目或 Ctrl-Shift-B 构建整个解决方案(这仅在您进行了更改时才需要,但我想我应该提及它,因为 F5 已经这样做了)。
  • Ctrl-Alt-P 打开附加到进程对话框

  • 然后输入“iis”将带您进入 iisexpress 过程

  • 按回车键,你就被连接了

If you have more than one iisexpress running, the last one started will generally appear at the top of the list. Another option is to shift-select and attach to all of them.

如果您有多个 iisexpress 正在运行,最后一个启动的通常会出现在列表的顶部。另一种选择是移动选择并附加到所有这些。

This has a number of advantages IMO. First and foremost, it doesn't terminate the process. Second, the browser window isn't closed when you stop debugging. It cracks me up when I see a developer repeat 7 steps to get to reproducing a bug, when all he needs to do is hit F5 in an existing browser window to just repost once the debugger is connected. Last, I have to do this already when attaching to nunit, so I get a more consistent experience.

这在 IMO 有许多优点。首先,它不会终止进程。其次,停止调试时浏览器窗口不会关闭。当我看到开发人员重复 7 个步骤来重现错误时,当他需要做的就是在现有浏览器窗口中按 F5 以在调试器连接后重新发布时,这让我感到震惊。最后,在附加到 nunit 时我必须已经这样做了,所以我得到了更一致的体验。