简体   繁体   English

调试时,有什么方法可以使Visual Studio在不打开浏览器窗口的情况下为我的Web API项目加载DLL。

[英]When debugging, is there any way to get Visual Studio to load DLLs for my Web API project without opening a browser window

I can make Visual Studio open my ASP.NET Web API in a new browser window, but that's annoying because I don't want a browser window to pop up. 我可以使Visual Studio在新的浏览器窗口中打开ASP.NET Web API,但这很烦人,因为我不想弹出浏览器窗口。 I want to go straight to Postman and start hitting endpoints. 我想直接去邮递员,并开始触碰端点。

Ideally I'd like to have Visual Studio try to run an endpoint (eg http://localhost:54292/token ) silently in the background, which will trigger the loading of most of the DLLs I need automatically. 理想情况下,我希望Visual Studio尝试在后台静默运行终结点(例如http:// localhost:54292 / token ),这将触发自动加载我需要的大多数DLL。

I know I can use the "start external program" feature and use something like cURL, but this opens a command window in the foreground, which is also annoying. 我知道我可以使用“启动外部程序”功能并使用类似cURL的功能,但这会在前台打开命令窗口,这也很烦人。

Is there any way to hide the command window, run my program minimized, or make it eager load DLLs when debugging? 有什么方法可以隐藏命令窗口,最小化运行我的程序,或使其在调试时急于加载DLL?

Choose the option "Don't open a page. Wait for a request from an external application", then use Postman after starting your debug session. 选择选项“不要打开页面。等待来自外部应用程序的请求”,然后在启动调试会话后使用Postman。

Alternatively, write a new windows form application and set that as the startup project. 或者,编写一个新的Windows窗体应用程序并将其设置为启动项目。 In that application, call the url you are interested in and remove the default form. 在该应用程序中,调用您感兴趣的URL并删除默认表单。 It will have no GUI. 它没有GUI。

You could also have the web application itself make a call into itself on startup by putting that code in your startup (globax.asax or startup.cs). 您也可以让Web应用程序本身在启动时对其进行调用,方法是将该代码放入启动中(globax.asax或startup.cs)。 You would probably want to remove this on deploy though, hence why I'd suggest a separate application. 您可能希望在部署时删除它,因此为什么我建议使用单独的应用程序。

please try below line of code if it helps you 如果有帮助,请尝试下面的代码行

            var proc1 = new ProcessStartInfo();
            proc1.FileName = @"cmd.exe";
            proc1.Verb = "runas";
            proc1.Arguments = "/c " + command;
            proc1.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(proc1);

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

相关问题 在Visual Studio 2012中打开Web项目时的奇怪行为 - Weird behavior when opening web project in Visual Studio 2012 visual studio在控制台应用程序而不是Web项目中打开Web浏览器+调试器 - visual studio opening web browser + debugger in a console app rather than a web project Visual Studio 2012中的Web项目调试和编码 - Web project Debugging & Coding in Visual Studio 2012 构建Visual Studio项目而无需访问引用的dll - Build a Visual Studio Project without access to referenced dlls 简单的注入器例外:启动Web API项目时无法加载dll - Simple Injector exception: cannot load dlls when web api project starts 在Visual Studio中记录Web负载测试项目 - Recording Web load test project in visual studio Visual Studio 2010 Silverlight项目在浏览器中以file://而不是localhost://打开 - Visual Studio 2010 Silverlight Project Opening in Browser as file:// instead of localhost:// 在Visual Studio中调试单元测试时,是否可以动态地附加到正在运行的Web应用程序? - When debugging unit tests in Visual Studio, is there a way to dynamically attach to a running web application? 在C#中使用Selenium而不在Visual Studio 2013中打开浏览器 - Using Selenium in C# without opening a browser in Visual Studio 2013 当将项目模板用于Visual Studio 2013时,此调试另一个项目 - When used project template for Visual Studio 2013 this debugging another project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM