【发布时间】:2016-06-27 16:54:51
【问题描述】:
我建立了一个非常简单的 asp.net mvc 网站(它不使用 asp.net 身份、实体框架,也不使用任何数据库)。这些是参考:
和 web.config
<configuration>
<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>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.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="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.WebPages" 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.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="info@domain.com">
<network host="smtp.domain.com" userName="info@domain.com" password="password" port="25" />
</smtp>
</mailSettings>
</system.net>
</configuration>
我将它发布在共享托管服务器上(使用 IIS 8.5),但遇到了安全异常:
描述:应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请联系您的系统管理员或在配置文件中更改应用程序的信任级别。
问题是为什么这个简单的网站需要完全信任? 我不明白,它是否需要完全信任,而不是任何 asp.net mvc 网站都需要完全信任。
更新:新的 .net 框架功能需要完全信任。我卸载了 Microsoft.CodeDom.Providers.DotNetCompilerPlatform 和 Microsoft.Net.Compilers 包,现在它可以工作了。
【问题讨论】:
-
已发布在共享主机服务器上,iis版本应为8.5
-
这个post 可能会有所帮助
-
@TasosK。我已经阅读过它,但我的 web.config 不包含您在主帖中看到的配置部分(我发布了 web.config)。
-
不可能说不知道什么是不允许的操作,以及应用了什么安全策略。您已定义 SMTP 设置。您确定您的共享主机提供商允许网站发送电子邮件吗?
-
@MikeMcCaughan 是的,我知道我没有更多细节。我可以确认托管服务提供商允许网站发送电子邮件
标签: asp.net .net asp.net-mvc security full-trust