Webmatrix网站 - 安全例外 - 不应该在那里

时间:2014-03-14 00:14:18

标签: c# asp.net .net securityexception

我刚刚上传了一个网站,它正在向我抛出一个安全例外。客户端不需要数据库或注册/登录功能甚至电子邮件设置,所以我没有使用这样的东西。

我在页面中的所有内容(目前只有一个页面,包含SiteLayout和Default.cshtml文件),只是普通的旧HTML和CSS。

错误和堆栈跟踪是:

Server Error in '/' Application.

Security Exception 
  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.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
   System.Security.CodeAccessPermission.Demand() +46
   System.Web.HttpContext.System.IServiceProvider.GetService(Type service) +54
   System.Web.HttpContextWrapper.GetService(Type serviceType) +11
   System.Web.WebPages.UrlRewriterHelper.IsUrlRewriterTurnedOn(HttpContextBase httpContext) +108
   System.Web.WebPages.UrlRewriterHelper.WasRequestRewritten(HttpContextBase httpContext) +13
   System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath) +138
   System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath) +103
   System.Web.WebPages.UrlUtil.GenerateClientUrl(HttpContextBase httpContext, String basePath, String path, Object[] pathParts) +144
   System.Web.WebPages.WebPageExecutingBase.Href(String path, Object[] pathParts) +44
   ASP._Page_Default_cshtml.Execute() +264
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198
   System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +69
   System.Web.WebPages.WebPage.ExecutePageHierarchy() +131
   System.Web.WebPages.StartPage.RunPage() +17
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +64
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +171
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContext context) +66
   System.Web.WebPages.WebPageHttpHandler.ProcessRequest(HttpContext context) +5
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

我完全不知道接下来要做什么。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

如果您使用的托管与其他网站共享,则应用程序安全级别可能设置为Medium Trust,并且您的应用程序的某些部分需要Full Trust

这篇文章解释了更多的中信任环境。

http://msdn.microsoft.com/en-us/library/ms998341.aspx#paght000020_step1