Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC app has SecurityException
    primarykey
    data
    text
    <p>I'm trying to get an ASP.NET MVC app working... I should have known it wouldn't be easy. The first few pages work, but they are all static. The first time a Controller is executed I get the exception below.</p> <p>Here is the Controller action method:</p> <pre><code>[AcceptVerbs(HttpVerbs.Get)] public ActionResult Index(Section? section, int? parent) { if (section == null) { return RedirectToAction("Index", "Questions", new {section = Section.Section0}); } IPagedList&lt;Question&gt; questions = _surveyService.FetchQuestions(User.Identity.Name, section.Value, parent); // ... ViewResult result = View("Index", questions); result.ViewData.Add("CurrentSection", section.Value); result.ViewData.Add("Parent", parent); result.ViewData.Add("IsLastPage", questions.IsLastPage); return result; } </code></pre> <p>The exception is thrown in the second line of the method at <code>RedirectToAction()</code>.</p> <p>Background:</p> <ul> <li>I've followed the instructions in <a href="https://stackoverflow.com/questions/266205/is-there-a-way-that-i-can-run-a-asp-net-mvc-project-on-godaddy-com-shared-web-hos/299339#299339">this answer</a>.</li> <li>I'm not using reflection or demanding security explicitly in my code.</li> <li>I'm using <strong>MVC</strong>, <strong>LINQ to SQL</strong>, <a href="http://code.google.com/p/elmah/" rel="nofollow noreferrer"><strong>Elmah</strong></a>, and <a href="http://pagedlist.codeplex.com/" rel="nofollow noreferrer"><strong>PagedList</strong></a>.</li> <li>I'm using <strong>IIS 7</strong> with <strong>Integrated</strong> mode.</li> <li>I added [<strong>assembly: AllowPartiallyTrustedCallers</strong>] to my AssemblyInfo.cs. I did this because I found another Stack Overflow question that had an answer recommending it (I can't find it now, or else I would provide a link). I also strong named my assemblies as suggested by Rex M's answer below.</li> </ul> <hr> <p>What am I missing to make this work?</p> <p>The exception:</p> <pre><code>Server Error in '/surveys/objectification' 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: That assembly does not allow partially trusted callers. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [SecurityException: That assembly does not allow partially trusted callers.] SelfObjectificationSurvey.Web.Controllers.QuestionsController.Index(Nullable`1 section, Nullable`1 parent) +0 lambda_method(ExecutionScope , ControllerBase , Object[] ) +123 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24 System.Web.Mvc.&lt;&gt;c__DisplayClassa.&lt;InvokeActionMethodWithFilters&gt;b__7() +53 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +258 System.Web.Mvc.&lt;&gt;c__DisplayClassc.&lt;InvokeActionMethodWithFilters&gt;b__9() +20 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +193 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +382 System.Web.Mvc.Controller.ExecuteCore() +123 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +23 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +144 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +54 System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75 Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.4049 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload