默认MVC 5应用程序的安全例外

时间:2014-11-29 07:18:24

标签: c# asp.net-mvc asp.net-mvc-5

在将使用VS 2013生成的默认MVC 5应用部署到我的主机帐户时,我遇到了安全性异常。

这个问题是否有快速解决方案?

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   Microsoft.Owin.Host.SystemWeb.Infrastructure.DefaultTraceFactory.InitializeTraceSource(String key) +0
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +72
   Microsoft.Owin.Host.SystemWeb.Infrastructure.DefaultTraceFactory.GetOrAddTraceSource(String name) +52
   Microsoft.Owin.Host.SystemWeb.Infrastructure.DefaultTraceFactory.Create(String name) +28
   Microsoft.Owin.Host.SystemWeb.OwinAppContext..ctor() +43
   Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action`1 startup) +30
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +70
   System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

谢谢, Khachatur

1 个答案:

答案 0 :(得分:3)

感谢您的回答。看起来我不能将MVC5用于我的托管服务(hostgator)。

  

现在的ASP.NET版本现在只支持完全信任。 MS有   在发行说明中说明:“ASP.NET MVC 5不再是已知问题”   支持部分信任......“。特别是[汇编:   AllowPartiallyTrustedCallers]属性已从中删除   源代码。您可以阅读有关ASP.NET官方立场的更多信息   Levi的回答是试图为了中等信任而失去原因,   其中还包括已删除支持的进一步链接。

请参阅: Deploying ASP.NET MVC Project