Asp.Net 没有 Owin 的 MVC 5?
Asp.Net MVC 5 without Owin?
Mvc 5 似乎依赖于 Owin,如果您想在 Mac 上自行托管或 运行,这非常好。但是假设我只想像以前的版本一样在 IIS 下 运行,并且我对 Owin 提供的内容不感兴趣。默认 "blank" mvc5 模板使用 owin 和其他 15 个依赖项。我试过一个一个地删除包,但似乎该站点不知道如何在不使用 Owin 的属性的情况下开始。那么,如何在没有 Owin 的情况下在 iis 下获得 ASP.net、mvc 5?
OWIN 只是一个标准,它将 ASP.net 应用程序与 IIS 分离,因此应用程序可以自托管,还有其他好处,但这并不意味着您不能在 IIS 中托管它们。
默认的 mvc5 模板使用 Identity 作为成员系统。 Identity 依赖于 Owin,因此这就是它包含在项目中的原因(与其他几个 'optional' 包一起)。如果您创建一个新的空项目并手动安装包 Microsoft.Aspnet.Mvc(使用命令 Install-Package Microsoft.Aspnet.Mvc
),您可以看到对 Owin 没有依赖性。
Obs:您还可以创建一个选中 'Add folders and core references for MVC' 选项的空项目。
禁用 Owin 的简单方法是在 web.config
文件和 <appSettings>
部分添加:
<add key="owin:AutomaticAppStartup" value="false" />
要完全删除 Owin,请右键单击您的项目,然后从菜单中单击 Manage Nuget Packages
。在 Manage Nuget Packages
window 的左侧,单击 Installed Package
,然后在 window 的右侧,在搜索框中键入 owin
。
按以下顺序卸载软件包:
- 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
- microsoft.aspnet.identity.core
打开 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>
删除项目根目录中的 Startup.cs
文件。打开 App_Start folder
并删除 IdentityConfig.cs
和 Startup.Auth.cs
文件。打开 Controller folder
并删除 AccountController.cs
和 ManageController.cs
。在 Models folder
中删除所有模型并在 View Folder
中删除 Account Folder
和 Manage folder
.
重新启动 Visual Studio 然后 运行 项目。如果您收到此错误:
The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No assembly found containing a Startup or [AssemblyName].Startup class. To disable OWIN startup discovery, add the appSetting
owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the
appSetting owin:AppStartup with the fully qualified startup class or
configuration method name in your web.config.
you have two ways to solve it:
- 打开
bin folder
,如果有Owin assembly
,全部删除
- 或在
<appSettings>
部分打开 web.config 然后添加此 <add key="owin:AutomaticAppStartup" value="false" />
我只是指定了完整的路线,它对我有用!!
Project name: Users.Web
Folders: App_Start
Class name: IdentityConfig
<add key="owin:AppStartup" value="Users.Web.App_Start.IdentityConfig" />
Mvc 5 似乎依赖于 Owin,如果您想在 Mac 上自行托管或 运行,这非常好。但是假设我只想像以前的版本一样在 IIS 下 运行,并且我对 Owin 提供的内容不感兴趣。默认 "blank" mvc5 模板使用 owin 和其他 15 个依赖项。我试过一个一个地删除包,但似乎该站点不知道如何在不使用 Owin 的属性的情况下开始。那么,如何在没有 Owin 的情况下在 iis 下获得 ASP.net、mvc 5?
OWIN 只是一个标准,它将 ASP.net 应用程序与 IIS 分离,因此应用程序可以自托管,还有其他好处,但这并不意味着您不能在 IIS 中托管它们。
默认的 mvc5 模板使用 Identity 作为成员系统。 Identity 依赖于 Owin,因此这就是它包含在项目中的原因(与其他几个 'optional' 包一起)。如果您创建一个新的空项目并手动安装包 Microsoft.Aspnet.Mvc(使用命令 Install-Package Microsoft.Aspnet.Mvc
),您可以看到对 Owin 没有依赖性。
Obs:您还可以创建一个选中 'Add folders and core references for MVC' 选项的空项目。
禁用 Owin 的简单方法是在 web.config
文件和 <appSettings>
部分添加:
<add key="owin:AutomaticAppStartup" value="false" />
要完全删除 Owin,请右键单击您的项目,然后从菜单中单击 Manage Nuget Packages
。在 Manage Nuget Packages
window 的左侧,单击 Installed Package
,然后在 window 的右侧,在搜索框中键入 owin
。
- 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
- microsoft.aspnet.identity.core
打开 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>
删除项目根目录中的 Startup.cs
文件。打开 App_Start folder
并删除 IdentityConfig.cs
和 Startup.Auth.cs
文件。打开 Controller folder
并删除 AccountController.cs
和 ManageController.cs
。在 Models folder
中删除所有模型并在 View Folder
中删除 Account Folder
和 Manage folder
.
重新启动 Visual Studio 然后 运行 项目。如果您收到此错误:
The following errors occurred while attempting to load the app. - No assembly found containing an OwinStartupAttribute. - No assembly found containing a Startup or [AssemblyName].Startup class. To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config. you have two ways to solve it:
- 打开
bin folder
,如果有Owin assembly
,全部删除 - 或在
<appSettings>
部分打开 web.config 然后添加此<add key="owin:AutomaticAppStartup" value="false" />
我只是指定了完整的路线,它对我有用!!
Project name: Users.Web
Folders: App_Start
Class name: IdentityConfig
<add key="owin:AppStartup" value="Users.Web.App_Start.IdentityConfig" />