asp.net-mvc-4 – WebAPI OData 5.0 Beta – 访问GlobalConfigur
我最近安装了WebApi OData 5.0框架的预发布版本,以便使用新的$expand支持.一切都建好了,但是我在App_Start上得到了一个奇怪的例外.
Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed. 源错误: Line 12: protected void Application_Start() Line 13: { Line 14: WebApiConfig.Register(GlobalConfiguration.Configuration); // <-- Line 15: } 堆栈跟踪: [TypeAccessException: Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.] System.Web.Http.GlobalConfiguration.get_Configuration() +0 API.WebApiApplication.Application_Start() in Global.asax.cs:14 [HttpException (0x80004005): Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context,HttpApplication app) +12863325 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext context,MethodInfo[] handlers) +175 System.Web.HttpApplication.InitSpecial(HttpApplicationState state,MethodInfo[] handlers,IntPtr appContext,HttpContext context) +304 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext context) +404 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475 [HttpException (0x80004005): Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12880068 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context) +12721257 Google显示的很少. 解决方法
在包管理器控制台中按照给定的顺序运行以下命令:
Uninstall-Package Microsoft.AspNet.Mvc.FixedDisplayModes Update-Package Microsoft.AspNet.Mvc -Pre Update-Package Microsoft.AspNet.WebApi -Pre Update-Package Microsoft.AspNet.WebApi.Tracing 现在,对web.config应用以下更改: >在项目的Web.config中,将应用设置网页值更新为3.0.0.0 <运行时间> < AssemblyBinding xmlns =“urn:schemas-microsoft-com:asm.v1”> < dependentAssembly> < assemblyIdentity name =“System.Web.Helpers”publicKeyToken =“31bf3856ad364e35”/> < bindingRedirect oldVersion =“1.0.0.0-3.0.0.0”newVersion =“3.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“System.Web.Mvc”publicKeyToken =“31bf3856ad364e35”/> < bindingRedirect oldVersion =“1.0.0.0-5.0.0.0”newVersion =“5.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“System.Web.WebPages”publicKeyToken =“31bf3856ad364e35”/> < bindingRedirect oldVersion =“1.0.0.0-3.0.0.0”newVersion =“3.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“EntityFramework”publicKeyToken =“b77a5c561934e089”/> < bindingRedirect oldVersion =“0.0.0.0-5.0.0.0”newVersion =“5.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“WebGrease”publicKeyToken =“31bf3856ad364e35”/> < bindingRedirect oldVersion =“0.0.0.0-1.3.0.0”newVersion =“1.3.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“System.Web.Http”publicKeyToken =“31bf3856ad364e35”culture =“neutral”/> < bindingRedirect oldVersion =“0.0.0.0-5.0.0.0”newVersion =“5.0.0.0”/> < / dependentAssembly> < dependentAssembly> < assemblyIdentity name =“System.Net.Http.Formatting”publicKeyToken =“31bf3856ad364e35”culture =“neutral”/> < bindingRedirect oldVersion =“0.0.0.0-5.0.0.0”newVersion =“5.0.0.0”/> < / dependentAssembly> < / assemblyBinding> < /运行> 从Views文件夹打开web.config.这里有三件事要更新: >在configSections下,将Razor程序集的版本更新为3.0.0.0. 如果您安装了Web API帮助页面,请检查以上装配体的配置. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – 如果Roles为空,则默认情况下使AuthorizeAtt
- asp.net – Session不会保留值并始终返回null
- asp.net-mvc – ASP.NET MVC中的AntiForgeryToken是否防止所
- asp.net-mvc – 是否可以在IIS服务器上部署asp.net mvc项目
- asp.net – 任何框架依赖于IIdentity.AuthenticationType?
- VS 2015 CTP 6 Nuget Package Source
- Asp.net MVC5与Bootstrap EditorFor尺寸
- asp.net-web-api – 将List转换为JSon并在Web API操作中返回
- asp.net – 将密码格式从加密更改为哈希
- asp.net-mvc – ASP.NET MVC 3 – 这个布尔值如何在控制器中