本文翻译自:OwinStartup not firing

I had the OwinStartup configuration code working perfectly and then it stopped working. 我的OwinStartup配置代码运行正常,然后停止运行。 Unfortunately I'm not sure exactly what I did to get it to stop working and am having a really hard time figuring it out. 不幸的是,我不确定到底要怎么做才能使其停止工作,并且很难弄清楚它。

To make sure I have the basics covered, I doubled checked to make sure the I have the 为了确保我了解基本知识,我仔细检查了一下以确保

[assembly:OwinStartup(typeof(WebApplication.Startup))]

attribute assigned properly and made sure that I don't have an appSetting for owin:AutomaticAppStartup that is set to false so I made one set to true to be safe as there was nothing there before. 属性已正确分配,并确保我没有将owin:AutomaticAppStartup的appSetting设置为false,所以我将其中之一设置为true是安全的,因为之前没有任何内容。

<add key="owin:AutomaticAppStartup" value="true" />

I also tried specifically calling out the appSetting: 我还尝试专门调出appSetting:

<add key="owin:appStartup" value="WebApplication.Startup" />

Before it stopped working I upgraded the Microsoft.Owin.Security NuGet packages to 2.0.2, so I tried reverting them to 2.0.1 (that was a pain) but it didn't change anything. 在它停止工作之前,我将Microsoft.Owin.Security NuGet软件包升级到2.0.2,因此我尝试将它们还原到2.0.1(这很痛苦),但是它没有任何改变。 I have WebActivator installed on the project and am using that to bootstrap other things but I've tested that on a fresh WebApplication template and it works there so I don't think that is the culprit. 我在项目上安装了WebActivator,并正在使用它来引导其他内容,但是我已经在新的WebApplication模板上对其进行了测试,并且该模板可以在其中工作,所以我认为这不是罪魁祸首。

I also tried removing my Startup class and using Visual Studio to add a new one using the OWIN Startup Class type in Add New Item and that isn't getting called either. 我还尝试删除了Startup类,并使用Visual Studio在“添加新项”中使用OWIN Startup类类型添加了一个新类,但没有一个被调用。 Next I tried adding a second Startup class since I know it will throw an exception if there is more than one OwinStartup attributes defined, but it isn't throwing any exception there. 接下来,我尝试添加第二个Startup类,因为我知道如果定义了多个OwinStartup属性,它将引发一个异常,但是在那里不会引发任何异常。

Not sure what else to try. 不知道还有什么尝试。 Any thoughts? 有什么想法吗?

Update 更新资料

Turns out that Resharper removed the reference to Microsoft.Owin.Host.SystemWeb when I used it to remove unused references. 事实证明,当我使用Resharper删除未使用的引用时,它删除了对Microsoft.Owin.Host.SystemWeb的引用。


#1楼

参考:https://stackoom.com/question/1Mlyg/OwinStartup不触发


#2楼

Make sure you have installed Microsoft.Owin.Host.SystemWeb package in the project. 确保已在项目中安装了Microsoft.Owin.Host.SystemWeb软件包。 This package is needed for startup detection in IIS hosted applications. 在IIS托管的应用程序中启动检测需要此软件包。 For more information you can refer to this article . 有关更多信息,请参考本文 。


#3楼

Alternative answer to the original problem discussed - Owin "not firing." 讨论的原始问题的替代答案-奥文“不开枪”。 In my case I spent hours thinking it wasn't firing due to being unable to set a breakpoint in it. 以我为例,我花了数小时以为它无法触发,因为无法在其中设置断点。

When debugging OWIN startup in visual studio 在Visual Studio中调试OWIN启动时

  • IIS Express - Running "F5" will break on the OWIN startup code IIS Express-运行“ F5”将在OWIN启动代码上中断

  • IIS - Running "F5" will not break until after OWIN (and global.asax) code is loaded. IIS-在加载OWIN(和global.asax)代码之后,运行“ F5” 不会中断。 If you attach to W3P.exe you will be able to step into it. 如果您附加到W3P.exe,则可以进入它。


#4楼

If you are having trouble debugging the code in the Startup class, I have also had this problem - or I thought I did. 如果您在调试Startup类中的代码时遇到问题,那么我也有这个问题-或我以为是。 The code was firing but I believe it happens before the debugger has attached so you cannot set breakpoints on the code and see what is happening. 代码正在触发,但是我相信它是在调试器附加之前发生的,因此您无法在代码上设置断点并查看正在发生的情况。

You can prove this by throwing an exception in the Configuration method of the Startup class. 您可以通过在Startup类的Configuration方法中引发异常来证明这一点。


#5楼

I had a similar issue to this and clearing Temporary ASP.NET Files fixed it. 我对此有类似的问题,并且清除了“临时ASP.NET文件”后将其修复。 Hope this helps someone. 希望这对某人有帮助。


#6楼

If you've upgraded from an older MVC version make sure you don't have 如果您是从较旧的MVC版本升级的,请确保没有

  <add key="owin:AutomaticAppStartup" value="false" />

in your web.config . 在您的web.config It will suppress calling the startup logic. 它将禁止调用启动逻辑。

Instead change it to true 而是将其更改为true

  <add key="owin:AutomaticAppStartup" value="true" />

I realize you already mentioned this but sometimes people (like me) don't read the whole question and just jump to the answers... 我意识到您已经提到了这个问题,但是有时候(像我这样的人)没有读完整的问题,而只是跳到答案...

Somewhere along the line - when I upgraded to MVC 5 this got added and I never saw it until today. 沿线的某个地方-当我升级到MVC 5时,添加了它,直到今天我才看到它。

OwinStartup不触发相关推荐

  1. Go 知识点(14) — Go 多协程(单个协程触发panic会导致其它所有协程挂掉,每个协程只能捕获到自己的 panic 不能捕获其它协程)

    在多协程并发环境下,我们常常会碰到以下两个问题.假设我们现在有 2 个协程,我们叫它们协程 A 和 B . [问题1]如果协程 A 发生了 panic ,协程 B 是否会因为协程 A 的 panic ...

  2. java线程触发_java线程

    线程. 状态 新建状态(New): 当用 new 操作符创建一个线程时, 例如 new Thread(r),线程还没有开始运行,此时 线程处在新建状态. 当一个线程处于新生状态时,程序还没有开始运行线 ...

  3. js 动态加载select触发事件

    动态加载select后,手动调用一下 subjectChange函数,模拟触发change事件 function hallidChange(value) {$.ajax({type: "po ...

  4. Go 学习笔记(19)— 函数(05)[如何触发 panic、触发 panic 延迟执行、panic 和 recover 的关系]

    1. 异常设计思想 Go 语言的错误处理思想及设计包含以下特征: 一个可能造成错误的函数,需要返回值中返回一个错误接口( error ),如果调用是成功的,错误接口将返回 nil ,否则返回错误. 在 ...

  5. java触发_怎么样让JAVA 设置一秒钟触发一个事件

    怎么使用javax.swing.Timer类,设置一秒钟触发一个动作事件,执行Time5对象中的increaseSecond()方法,在命令行将时间显示出来,Time5类代码如下:file://=== ...

  6. 【longPressKey】长按键盘任意键(或组合键)3秒触发自定义事件(以Pause/Break键为例)

    <!doctype html> <html lang="en"> <head><meta charset="UTF-8" ...

  7. 封装echarts china map geo实现dispatch触发geoSelect事件高亮显示某个省份和城市,并定义复杂样式

    实现如下效果 用echarts geo类型的中国地图封装vue组件,具体的地图信息china.json传送门https://blog.csdn.net/qq_37860634/article/deta ...

  8. 在C#中使用代理的方式触发事件

    事件(event)是一个非常重要的概念,我们的程序时刻都在触发和接收着各种事件:鼠标点击事件,键盘事件,以及处理操作系统的各种事件.所谓事件就是由某个对象发出的消息.比如用户按下了某个按钮,某个文件发 ...

  9. Combox控件下拉选择不同值触发的动作响应

    项目中需要根据combox控件下拉列表选择不同的值,然后能触发相应的动作.比如我的项目中,通过combox空间的下拉列表选择不同的C盘,D盘,E盘,F盘,然后能在list控件中把各个盘符的文件目录列出 ...

最新文章

  1. SAP WM 二步法确认TO场景下WM库存状态变化
  2. c语言 二级菜单_收下计算机二级秘笈,考场上说好不哭!
  3. mysql更新视图的时候有时候可以不满足视图条件的值也能更新成功
  4. android调用fragment的方法,AndroidX下使用Activity和Fragment的变化
  5. java JLabel改变大小后如何刷新_到底一行java代码是如何在计算机上执行的
  6. 50道编程小题目之【企业利润提成】
  7. 大数据时代必须关注的几个问题
  8. SaaS 正在 Rails 化
  9. Linux小知识收集(不断更新)
  10. SVM支持向量和逻辑回归的decision_function用法详解
  11. 张小平,海底捞,比特大陆
  12. 用python写问答机器人_机器人之Python入门到实践-问答机器人
  13. hapi_带有节点和Hapi后端的Angular文件上传
  14. Android 系统第三方应用系统修改权限及在应用上层显示权限默认打开
  15. Jmeter分布式压测-windows(master控制机)多个linux(slaves负载机)监测服务器资源(cpu、内存等)
  16. java生成word(报告报表)含统计图表图片、循环表格,Spring Boot整合word生成
  17. 创建订单【项目 商城】
  18. 开源python-向timm学习
  19. 长按Home键唤起Google Search
  20. java程序员—工作中开发经验总结

热门文章

  1. HasMany() = (1..*) HasOptional() = (1..0,1) HasRequired() = (1..1)
  2. Android Studio(五):修改Android Studio项目包名
  3. Struts2零配置属性详解(2)
  4. 浅析Windows计算机中丢失SETUPAPI.dll的问题
  5. 何时创建MVC应用程序
  6. E72上安装fring使用skypeout拨打电话
  7. [译]发布ABP v0.19包含Angular UI选项
  8. Oracle 数据库逻辑结构.md
  9. Android Theme主题
  10. mac install brew