Asp.Net MVC 5没有Owin? [英] Asp.Net MVC 5 without Owin?
问题描述
5的mvc似乎取决于Owin,与如果你想自主机或Mac上运行是很大的。但是让我们假设我只是想在IIS下运行,就像previous版本,我不感兴趣的是Owin所提供的。默认的空白mvc5模板使用owin等15个依赖。我试着删除软件包一个接一个,但它似乎喜欢的网站不知道如何不使用来自Owin的属性开始。所以,我怎么得到的只是ASP.net,MVC 5,IIS下没有Owin?
最简单的方法来禁用Owin是的web.config
文件和 <&的appSettings GT;
部分补充一点:
<添加键=owin:AutomaticAppStartupVALUE =FALSE/>
要删除Owin完全右击你的项目,并从菜单中点击管理的NuGet包
。在安装包上的
然后在窗口右侧的搜索框中键入左侧管理的NuGet包
窗口中点击 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
文件,并删除该段<运行>< assemblyBinding的xmlns =瓮:架构 - 微软COM: asm.v1>
:
< dependentAssembly>
< assemblyIdentity名称=Microsoft.Owin公钥=31bf3856ad364e35/>
< bindingRedirect oldVersion =1.0.0.0-3.0.0.0NEWVERSION =3.0.0.0/>
< / dependentAssembly>
< dependentAssembly>
< assemblyIdentity名称=Microsoft.Owin.Security.OAuth公钥=31bf3856ad364e35/>
< bindingRedirect oldVersion =1.0.0.0-3.0.0.0NEWVERSION =3.0.0.0/>
< / dependentAssembly>
< dependentAssembly>
< assemblyIdentity名称=Microsoft.Owin.Security.Cookies公钥=31bf3856ad364e35/>
< bindingRedirect oldVersion =1.0.0.0-3.0.0.0NEWVERSION =3.0.0.0/>
< / dependentAssembly>
< dependentAssembly>
< assemblyIdentity名称=Microsoft.Owin.Security公钥=31bf3856ad364e35/>
< bindingRedirect oldVersion =1.0.0.0-3.0.0.0NEWVERSION =3.0.0.0/>
< / dependentAssembly>
在项目的根目录中删除 Startup.cs
文件。打开 App_Start文件夹
并删除 IdentityConfig.cs
和 Startup.Auth.cs
文件。打开控制器文件夹
并删除 AccountController.cs
和 ManageController.cs
。在 Models文件夹
删除所有车型,并在查看文件夹
删除帐户文件夹
和管理文件夹
。
重新启动Visual Studio和后运行该项目。如果你得到这个错误:
尝试加载应用程序时出现以下错误。
- 未组装找到包含OwinStartupAttribute。
- 未组装找到包含启动或[的AssemblyName] .STARTUP类。要禁用OWIN启动发现,添加appSetting
owin:AutomaticAppStartup在你的web.config一的假的价值。
要指定OWIN启动大会,类或方法,添加
appSetting owin:AppStartup具有完全限定启动类或
在你的web.config配置方法名。
您有两种方法来解决这个问题:
块引用>
- 开启
bin文件夹
如果有任何Owin组装
,全部删除- 或者在露天的web.config
<的appSettings>
部分,然后添加此<添加键=owin:AutomaticAppStartupVALUE =假/>
Mvc 5 seems to depend on Owin, with is great if you want to self host or run on a Mac. But lets assume I just want to run under IIS just like the previous versions and I'm not interested in what Owin has to offer. The default "blank" mvc5 template uses owin and 15 other dependencies. I've tried removing packages one by one but it seems like the site didn't know how to start without using an attribute from Owin. So, how do I get just ASP.net, mvc 5, under iis without Owin?
解决方案The easy way to disable Owin is in
web.config
file and in<appSettings>
section add this:
<add key="owin:AutomaticAppStartup" value="false" />
To remove Owin completely right click on your project and from menu click on
Manage Nuget Packages
. on left side ofManage Nuget Packages
window click onInstalled Package
then on right side of window in search box typeowin
.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
and after removing
microsoft.owin.security.twitter
other owin packages removed automatically and if it does not happened on your machine remove the others by yourself. then remove this packages:
- microsoft.aspnet.identity.entityframework
- microsoft.aspnet.identity.core
Open
web.config
file and remove this sections from<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
file in root of the project. openApp_Start folder
and removeIdentityConfig.cs
andStartup.Auth.cs
files. openController folder
and removeAccountController.cs
andManageController.cs
. inModels folder
Delete all Models and inView Folder
RemoveAccount Folder
andManage folder
.Restarts Visual Studio and after that run the project. if you get this error:
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:
- Open
bin folder
and if there is anyOwin assembly
, delete all of them- Or open web.config in
<appSettings>
section then add this<add key="owin:AutomaticAppStartup" value="false" />
这篇关于Asp.Net MVC 5没有Owin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!