我刚刚在 Visual Studio 2013 中创建了一个简单的 mvc-5 应用程序,只有几个页面。在开发环境中,它工作正常,但是当我将其上传到 GoDaddy 服务器时,它会抛出以下异常
[MethodAccessException: Attempt by security transparent method 'Vertance.MvcApplication.Application_Start()' to access security critical method 'System.Web.Mvc.AreaRegistration.RegisterAllAreas()' failed.
当我检查本地计算机上的版本信息时,它显示以下内容
.NET framework versions: 4.0.30319
Asp.Net Version: 4.0.30319.34209
服务器上的版本信息如下
.Net Framework Version: 4.0.30319 (same as on local machine)
Asp.Net Version: 4.0.30319.34280 (different from local machine)
可能是什么问题?为什么会发生这种情况?
编辑 1:我还在 AssemblyInfo.cs 文件中添加了以下属性
[assembly: SecurityCritical()]
但它也不起作用。
最佳答案
通过在 system.web
设置下的 web.config
中添加 Trust
元素解决了该问题,例如
<system.web>
<trust level="Full"/>
.....
......
</system.web>
关于asp.net - 在服务器上上传时 Asp.net mvc-5 应用程序中的 MethodAccessException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35717814/