如果项目未通过IIS Express设置为“启动",则OWIN无法启动 [英] OWIN not firing up if project not set as Startup with IIS Express

查看:138
本文介绍了如果项目未通过IIS Express设置为“启动",则OWIN无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2013中具有以下设置的解决方案:

I have a solution in VS2013 with the following setup:

  • App.Web(仅包含静态文件的Web项目)
  • App.Web.API(带有OWIN的Web API项目)

这两个项目都有一个指向其拥有 localhost:portX的默认URL(我正在使用IIS Express),因此App.Web在localhost:2222上侦听,而APP.Web.API在侦听localhost:2222.在本地主机上:3333.

Both the projects have a default url pointing to their own localhost:portX (I am using IIS Express), so App.Web is listening on localhost:2222 and APP.Web.API is listening on localhost:3333.

我将App.Web.API设置为使用OWIN,并为IIS中的自动启动添加了包 Microsoft.Owin.Host.SystemWeb .

I set up the App.Web.API to use OWIN and I added the package Microsoft.Owin.Host.SystemWeb for the autofire up in IIS.

我在OWIN启动类的配置方法中添加了一个断点.

I put a breakpoint in the configuration method of the OWIN startup class.

当我在VS2013中将APP.Web.API设置为启动项目"时,会遇到断点.

When I set the APP.Web.API as "startup project" in VS2013 the breakpoint is hitted.

但是,一旦我将App.Web设置为启动项目",然后从浏览器向App.Web.Api发出请求,就不会再遇到Startup类的断点了.

But as soon I set the App.Web as "startup project" and then from the browser I make a request to the App.Web.Api, the breakpoint at the Startup class is not hitted anymore.

我试图遵循在网上找到的一些建议(清理IIS Temp文件,使用OWIN attibute等.),但是它不起作用.

I tried to follow some suggestions found on the net (cleanup IIS Temp files, using OWIN attibute etc..) but it's not working.

似乎使用IIS Express,只有包含OWIN的项目设置为启动项目"时,OWIN才会启动.

It seems that with IIS Express the OWIN is only firing up if the project containing it is set as Startup Project.

有人可以解释发生了什么事吗?

Can someone explain what is happening?

推荐答案

您的解决方案中只能有一个项目设为启动项目".该项目将成为您应用程序的起点,并且您可以基于此起点"来调试应用程序.

You can only have one project "Set as StartUp project" in your solution. This project will be the Start point of you App, and you can debug your application based on this "Start Point".

将App.Web.API设置为启动项目时,将能够在Web Api的Startup.cs中调试应用程序.

When you setup your App.Web.API as your Startup project, you will be able to debug your application in the Startup.cs of your Web Api.

将App.Web设置为Startup项目时,将无法在Web Api项目的Startup.cs中调试应用程序,因为Startup.cs是由Web Api项目而不是您的Web应用程序触发的App.Web项目.

When you setup your App.Web as your Startup project, you wouldn't be able to debug your application in Startup.cs of the Web Api project, because the Startup.cs is fired by your Web Api project, not your App.Web project.

红色断点按钮可以为您提供帮助.如果您在Startup.cs中设置一个断点并启动App.Web项目,则会注意到该断点具有透明颜色,带有警告符号和以下消息:该断点当前不会被击中.该文档尚未加载任何符号." .这意味着根据您的起点",无法获得此代码点.

Something that can help you is the red breakpoint button. If you set a breakpoint in the Startup.cs and you Start your App.Web project, you will be notice that the break point has a transparent color, with a warning symbol and the following message: "The breakpoint will not currently be hit. No symbols have been loaded for this document.". This means that based on your "Start Point", there's no way to get this code point.

因此,在您的情况下,当您从App.Web项目中调试应用程序时,Web Api方法之所以有效,是因为您已经将项目附加到IIS,并且启动了Startup.cs,但不是通过调试过程进行的,这就是没有触发断点的原因.

So in your case, when you debuged your application from App.Web project, the Web Api methods were working because you had the project already attached to the IIS, and the Startup.cs was fired, but not by your debuging process, that's why the breakpoint had not fired.

这篇关于如果项目未通过IIS Express设置为“启动",则OWIN无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆