禁用 Owin 的简单方法是web.config
文件并在<appSettings>
部分添加以下内容:
<add key="owin:AutomaticAppStartup" value="false" />
要完全删除 Owin,请右键单击您的项目,然后从菜单中单击Manage Nuget Packages
。在左侧Manage Nuget Packages
窗口点击Installed Package
然后在窗口右侧的搜索框中输入owin
.
uninstall packages in order of:
- microsoft.aspnet.identity.owin
- microsoft.owin.host.systemweb
- microsoft.owin.security.cookies
- microsoft.owin.security.facebook
- microsoft.owin.security.google
- microsoft.owin.security.microsoftaccount
- microsoft.owin.security.twitter
并删除后microsoft.owin.security.twitter
其他 owin 软件包会自动删除,如果您的计算机上没有发生这种情况,请自行删除其他软件包。
然后删除这个包:
- microsoft.aspnet.identity.entityframework
- 微软.aspnet.identity.core
Open web.config
文件并从中删除这些部分<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
Remove Startup.cs
文件位于项目的根目录中。打开App_Start folder
并删除IdentityConfig.cs
and Startup.Auth.cs
文件。打开Controller folder
并删除AccountController.cs
and ManageController.cs
. in Models folder
删除所有模型并在View Folder
Remove Account Folder
and Manage folder
.
重新启动 Visual Studio,然后运行项目。如果您收到此错误:
尝试加载应用程序时发生以下错误。
- 未找到包含 OwinStartupAttribute 的程序集。
- 未找到包含 Startup 或 [AssemblyName].Startup 类的程序集。要禁用 OWIN 启动发现,请添加 appSetting
owin:AutomaticAppStartup 在 web.config 中的值为“false”。
要指定 OWIN 启动程序集、类或方法,请添加
appSetting owin:AppStartup 具有完全限定的启动类或
web.config 中的配置方法名称。
你有两种方法可以解决它:
- Open
bin folder
如果有的话Owin assembly
,全部删除
- 或者打开 web.config 在
<appSettings>
部分然后添加这个<add key="owin:AutomaticAppStartup" value="false" />