Visual Studio 2013 Web窗体站点不适用于信任级别为"Medium"的网站 [英] Visual Studio 2013 Web Forms Site doesn't work with trust level "Medium"

查看:84
本文介绍了Visual Studio 2013 Web窗体站点不适用于信任级别为"Medium"的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Visual Studio 2013创建了一个asp.net Web窗体网站.脚本和页面是由VS 2013自动生成的.问题是该网站不适用于.Net信任级别中".它要求完全"级别.

I've created an asp.net Web Forms site with Visual Studio 2013. Scripts and pages are generated automatically by VS 2013. The problem is that the website doesn't work with the .Net trust level "Medium". It reqires "Full" level.

使用中"级别会引发错误:

With the "Medium" Level it throws an error:

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

 [SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Delegate.DelegateConstruct(Object target, IntPtr slot) +0
Owin.Loader.DefaultLoader..ctor(Func`3 next, Func`2 activator, IEnumerable`1 referencedAssemblies) +69
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +65
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
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

我了解该问题与IIS信任级别有关.

I understand that the issue is related to the IIS trust level.

我的问题是

  1. 是否有办法使网站的信任级别为中".原因是我的主机共享服务器不允许完全信任.

  1. Is there a way around to make the website work with trust level "Medium". The reason is that my host sharing server doesn't allow Full trust.

如何跟踪导致此错误行为的脚本.

How to trace the script that is causing this error behavior.

先谢谢您....

推荐答案

Medium Trust已死.我们(ASP.NET团队)不再支持它了:SignalR,MVC 5,Web API 2,Friendly URL和Katana堆栈等我们最近的框架都要求使用完全信任.有关更多信息,请参见 https://stackoverflow.com/a/17218344/59641 .

Medium Trust is dead. We (the ASP.NET team) no longer support it going forward: our recent frameworks like SignalR, MVC 5, Web API 2, Friendly URLs, and the Katana stack all mandate the use of Full Trust. See https://stackoverflow.com/a/17218344/59641 for more information.

您可以选择以下几种方式:

You have a few options at your disposal:

  • 联系您的房东,并要求他们将您的网站移至完全信任". KB2698981 为托管者提供了指导,告诉托管者他们应该脱离ASP.NET的部分信任模式,并且使用操作系统提供的适当隔离级别,以完全信任的方式运行所有内容.

  • Contact your host and ask them to move your site to Full Trust. KB2698981 gives guidance to hosters telling them that they should move off of ASP.NET's partial trust modes and run everything in Full Trust with the proper OS-provided isolation levels.

移动到另一个不限制您成为中等信任度的托管人.

Move to a different hoster that doesn't limit you to Medium Trust.

如果必须使用现有的宿主,并且它们不会将您转移到完全信任",请使用旧版本的ASP.NET项目模板(文件"->新建"->项目"->"Visual C#- > Web-> Visual Studio 2012-> {选择应用程序类型}).或者,您可以从空的ASP.NET项目模板开始.这些模板不需要完全信任.但是,请注意,您将限制站点可用的功能,并且您将无法安装ASP.NET团队提供的最新NuGet软件包.

If you must use your existing hoster and they will not move you to Full Trust, use the older versions of the ASP.NET project templates (File -> New -> Project -> Visual C# -> Web -> Visual Studio 2012 -> { select app type }). Alternatively, you can start with the empty ASP.NET project template. These templates do not require Full Trust. However, take note that you'll be limiting the functionality available to your site, and you won't be able to install the latest NuGet packages provided by the ASP.NET team.

这篇关于Visual Studio 2013 Web窗体站点不适用于信任级别为"Medium"的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆