没有owin.Environment项目被发现在上下文下文、在上、发现、项目

2023-09-02 21:35:10 作者:猥琐控。

微软最近introduced新的ASP.NET身份 - 取代旧的(简单的)成员。不幸的是,我不能使用这个新的会员系统,我的老项目,因为它会抛出System.InvalidOperationException:没有owin.Environment项目被发现在上下文中。这是一个已知bug,但微软保持沉默这个问题。产生此错误的最简单的方法 - 这是创建一个新的Web应用程序(MVC,WebForms的或的WebAPI - 无所谓)在VS 2013(使用Web工具的2013 preVIEW刷新),然后进入登录页面。它将工作。然后在你的应用程序中更改命名空间什么都较原来的命名空间和登录页面会抛出这个错误。更改命名回原来的(你用在创建项目的一种)会解决这个问题。

Microsoft recently introduced new ASP.NET Identity - replacement for old (Simple)Membership. Unfortunately, I can't use this new membership system in my old project because it throws System.InvalidOperationException: No owin.Environment item was found in the context. This is a known bug, but Microsoft keeps silence about this issue. The easiest way to reproduce this bug - it's to create a new web application (MVC, WebForms or WebApi - doesn't matter) in VS 2013 (with Web Tools 2013 Preview Refresh) and then go to the login page. It will work. Then change namespace in your application to anything else than original namespace and login page will throw that error. Changing namespace back to original (the one you used at the creation of a project) will solve this problem.

它看起来像.NET存储地方一些相关的原始命名空间,但我找不到什么,在哪里,它不是在项目文件夹。我知道,计算器不是一个bug报告,我只是希望有人已经发现了针对此问题的解决方案,或者人参与ASP.NET身份的发展会看到这样的地方。

It looks like .net stores somewhere something related to the original namespace, but I can't find what and where, it's not in the project folder. I know that stackoverflow is not a place for a bug reports, I just hoping that someone already found a solution for this issue or maybe people involved in the development of ASP.NET Identity will see this.

推荐答案

最有可能找不到OWIN启动类。对于启动类的默认约定是[的AssemblyName] .STARTUP。如果你不再下的约定,你需要在web.config中指定的启动类的全名。     

Most likely it cannot find the OWIN Startup class. The default convention for the Startup class is [AssemblyName].Startup. If you're no longer following that convention you'll need to specify the full name of your Startup class in the Web.Config.

Microsoft.Owin.Host.SystemWeb包的下一个版本,现在抛出异常的详细消息时,启动类不能被找到。

The next release of Microsoft.Owin.Host.SystemWeb package now throws detailed exception messages when the Startup class cannot be found.