1

I have just uploaded a site and it's throwing a Security Exception at me. The client does not need a database or Register/Login functionality or even email setup, so I am not using anything like that.

All I have in my pages (just one page at the moment, with a SiteLayout and Default.cshtml file), is just plain old HTML and CSS.

The error and stacktrace is:

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

I'm completely stumped as to what to do next. Any help will be greatly appreciated!

uSeRnAmEhAhAhAhAhA
  • 2,527
  • 6
  • 39
  • 64

1 Answers1

1

If the hosting you are using is shared with another websites, it's likely that the application security level is set to Medium Trust and some part of your application requires Full Trust.

Here is an article that explains a bit more of Medium Trust environments.

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

ThiagoPXP
  • 5,362
  • 3
  • 31
  • 44
  • It's WinHost Shared hosting. Windows Hosting. I've been using them for years. This is a new client with a new account. I did set trustLevel="Full" in config file but it hasn't changed anything. – uSeRnAmEhAhAhAhAhA Mar 14 '14 at 00:28
  • 1
    If the hosting is settings it in the Machine.Config or in IIS for applications, it would overwrite your setting in the Web.Config. Check with the hosting company if that is the case – ThiagoPXP Mar 14 '14 at 00:29
  • Thanks @Thiago, I will contact them. – uSeRnAmEhAhAhAhAhA Mar 14 '14 at 00:33
  • I just realised, on their Support Portal, "Changing the ASP.NET Trust Level" is one of their most popular pages lol – uSeRnAmEhAhAhAhAhA Mar 14 '14 at 00:35
  • Problem is solved. I opened up IIS (after deleting all trust level stuff from web.config file) and set it to full trust inside IIS. It's now working. – uSeRnAmEhAhAhAhAhA Mar 14 '14 at 00:46