简体   繁体   English

在 F5 上附加到 IIS

[英]Attach to IIS on F5

I have a library project in Visual Studio which is deployed as part of web site.我在 Visual Studio 中有一个库项目,它作为网站的一部分进行部署。 Now I debug it attaching every time to IIS process, but it is really irritating.现在我每次都调试它附加到 IIS 进程,但它真的很烦人。

Is there a way to configure C# Library project to attach to IIS on F5?有没有办法配置 C# 库项目以附加到 F5 上的 IIS? I am using VS2010 and VS2012.我正在使用 VS2010 和 VS2012。

Small update I have usually more than one w3wp process running on my machine.小更新我的机器上通常运行不止一个 w3wp 进程。

I do use the AttachTo Visual Studio Extension.我确实使用了AttachTo Visual Studio 扩展。 It provides shortcuts under the tool menu:它在工具菜单下提供了快捷方式:在此处输入图片说明

And attaching the debugger takes half a second.连接调试器需要半秒钟。 A really great tool :)一个非常棒的工具:)

I don't think that's available by default.我认为默认情况下不可用。

You could use reattach : http://visualstudiogallery.msdn.microsoft.com/8cccc206-b9de-42ef-8f5a-160ad0f017ae for easing the process to attach every time.您可以使用重新附加: http : //visualstudiogallery.msdn.microsoft.com/8cccc206-b9de-42ef-8f5a-160ad0f017ae以简化每次附加的过程。

Solution 1:解决方案1:
I think you could do something like as below in the .csproj file to configure the project in IIS.我认为您可以在 .csproj 文件中执行如下操作以在 IIS 中配置项目。

  • As you open the project in visual studio it will automatically configure the project as web site in local IIS.当您在 Visual Studio 中打开项目时,它会自动将项目配置为本地 IIS 中的网站。
  • When you will press F5 it will run from IIS.当您按 F5 时,它将从 IIS 运行。
  • Change the <IISUrl>http://www.site.com/MySampleWebsite</IISUrl> to your specific while copying.复制时将<IISUrl>http://www.site.com/MySampleWebsite</IISUrl>更改为您的特定内容。

     <Project> <!-- Some more tags here such as PropertyGroup, and Imports, etc --> <ProjectExtensions> <VisualStudio> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <WebProjectProperties> <UseIIS>True</UseIIS> <AutoAssignPort>True</AutoAssignPort> <DevelopmentServerPort>8080</DevelopmentServerPort> <DevelopmentServerVPath>/</DevelopmentServerVPath> <IISUrl>http://www.site.com/MySampleWebsite</IISUrl> <NTLMAuthentication>False</NTLMAuthentication> <UseCustomServer>False</UseCustomServer> <CustomServerUrl> </CustomServerUrl> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> </WebProjectProperties> </FlavorProperties> </VisualStudio> </ProjectExtensions> </Project>

Solution 2:解决方案2:

Use of keyboard shortcut键盘快捷键的使用

  • Keyboard solution steps键盘解决步骤

    1. Press alt + ctrl + palt + ctrl + p
    2. Press w , So it would highlight to w3wp.exe process in the list.w ,它会突出显示列表中的 w3wp.exe 进程。
    3. Select all the w3wp process items at once.一次选择所有 w3wp 流程项目。
    4. Select Ok and you're done.选择确定,你就完成了。

Solution 3:解决方案3:

Configuration of Web application project in IIS via Visual Studio properties window通过 Visual Studio 属性窗口在 IIS 中配置 Web 应用程序项目

You could configure the settings from visual studio wizard when your project is an web application project .当您的项目是Web 应用程序项目时,您可以从 Visual Studio 向导配置设置。 Just right click on the project and open Properties > select 'Web' from left side menu and then check the settings from below screen.只需右键单击该项目并打开“ Properties > 从左侧菜单中选择“Web”,然后从屏幕下方检查设置。 Configure your website url by checking Use local IIS Web server then below it Override applicationroot URL and enter the url path as shown in image or as per your needs.通过选中Use local IIS Web server然后在其下方Override applicationroot URL并输入 url 路径来配置您的网站 url,如图所示或根据您的需要。

通过 Visual Studio 属性窗口在 IIS 中配置 Web 应用程序项目

PS: Solution 3 is similar to Solution 1 but follows visual studio wizard for acheiving the same. PS:解决方案 3 与解决方案 1 类似,但遵循 Visual Studio 向导来实现相同的目标。 But Solution 3 seems having less visually options regarding the IIS configurations for Virtual Directory and Application Pool.但解决方案 3 似乎在虚拟目录和应用程序池的 IIS 配置方面具有较少的视觉选项。

In VS2010 you can do this - http://www.c-sharpcorner.com/UploadFile/vendettamit/auto-attach-debugger-to-any-process-in-visual-studio/ , in 2012 unfortunately macros have been removed. 在VS2010,你可以做到这一点- http://www.c-sharpcorner.com/UploadFile/vendettamit/auto-attach-debugger-to-any-process-in-visual-studio/ ,在2012年不幸宏已被删除。

Haven´t tried this for years but I think this should still work too (but for IISExpress): http://weblogs.asp.net/nmarun/archive/2011/05/05/attach-to-iisexpress-process-from-visual-studio.aspx 多年没有尝试过,但是我认为这也应该可以工作(但对于IISExpress): http ://weblogs.asp.net/nmarun/archive/2011/05/05/attach-to-iisexpress-process-from -visual-studio.aspx

Reattach to process is now supported in Visual Studio natively, you don't need a plugin.现在,Visual Studio 本身支持重新附加到进程,您不需要插件。

https://docs.microsoft.com/en-us/visualstudio/debugger/attach-to-running-processes-with-the-visual-studio-debugger https://docs.microsoft.com/en-us/visualstudio/debugger/attach-to-running-processes-with-the-visual-studio-debugger

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM