如何在新VS2013 Asp.net模板中禁用System.Security.Permissions.ReflectionPermission用法,使其在共享主机上工作
我使用默认的MVC模板创建了一个全新的Visual Studio 2013 ASp.net MVC应用程序。但是,我收到一条错误消息,请求“System.Security.Permissions.ReflectionPermission”类型的权限失败 是否可以关闭此反射权限以使站点仍然工作 这是我的web.config如何在新VS2013 Asp.net模板中禁用System.Security.Permissions.ReflectionPermission用法,使其在共享主机上工作,reflection,deployment,asp.net-4.5,visual-studio-2013,owin,Reflection,Deployment,Asp.net 4.5,Visual Studio 2013,Owin,我使用默认的MVC模板创建了一个全新的Visual Studio 2013 ASp.net MVC应用程序。但是,我收到一条错误消息,请求“System.Security.Permissions.ReflectionPermission”类型的权限失败 是否可以关闭此反射权限以使站点仍然工作 这是我的web.config <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="MyDb" connectionString="Data Source=x.x.com;Initial Catalog=x;User Id=x;Password=x;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<trust level="Full" />
<customErrors mode="Off"/>
<authentication mode="None" />
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
</system.webServer>
<runtime>
<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="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
到我的Web.Config system.Web部分,但由于我得到了一个
无法在此路径上使用此配置节。当站点管理员使用继承的配置文件锁定对此节的访问时,会发生这种情况
它是1和1.com上的共享主机,他们不会完全信任我。Microsoft.Owin.Host.SystemWeb软件包不支持部分信任。这是帮助运行的包。此程序集执行反射以检测和加载OWIN启动类。您可以通过添加应用设置来关闭此功能,但不幸的是,OWIN中间件将无法工作,因为启动检测已禁用。简短回答-不可能在部分信任的情况下运行 我直接询问了asp.net团队,这是他们的回答 去年我们正式宣布,出于应用程序隔离的目的()部分信任不再是信任边界,因此我们建议共享主机提供商不再使用它。向前看,我们将不支持基于此原因开发的新框架特性的部分信任 我知道很多人都在使用共享主机,由于主机提供商永远不会完全信任他们的共享主机产品,我猜微软是为了在Azure上获得更多客户而做出这一决定的 让我们这些在共享主机上销售客户的小型开发人员陷入困境。要么转到更昂贵的主机,要么跳到azure。 解决方案4 System.Security.SecurityException:请求“System.Net.SocketPermission,System,Version=4.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”类型的权限失败 上述错误的后续解决方案
<system.web>
<customErrors mode="Off"/>
<trust level="Full" />
</system.web>
在GoDaddy Plesk上为我的en godady主机运行7.2.x时,我遇到了安全问题 我的解决方案是将customErrors下面的信任级别手动添加到我的web.config(如果使用godaddy仪表板添加该级别,它会将其特定于umbraco目录,而不是网站的上根目录)
如果您有以下情况: 1) 由于强制安全要求,必须使用中等或更低级别的信任 2) 使用ASP.NET4.5 3) 不需要使用Owin来允许外部身份验证提供商,如Google或Facebook 4) 应用程序错误信息显示Owin参与阻止应用程序在中等信任下启动 您可以将以下行添加到web.config AppSettings部分以禁用Owin,并且您应该能够使程序以中等信任级别运行:
<add key="owin:AutomaticAppStartup" value="false" />
不仅仅是MVC模板或OWIN包。不再在所有ASP.NET中支持中等信任。有关更多信息,请参阅我的回复。在godaddy上也为我工作。在godaddy上也为我工作。在所有子目录上添加时也为我工作
<add key="owin:AutomaticAppStartup" value="false" />