1

I'm trying to deploy the default MVC project (from Visual Studio 2013) onto a remote server. They require the program to be running in Medium Trust mode, which I am having issues with. I've added <trust level="Medium" originUrl="" /> to the <system.web> section of Web.config. Then when I try to run the program on my local machine, a SecurityException is thrown by this line:

@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })

This is located in the _Layout.cshtml file, which I haven't modified from the generated template (when you create a new MVC 5 project).

My question is: what do I need to do to get my project to run in Medium Trust mode?

Mr_Bean
  • 139
  • 1
  • 15
  • Have a look at [this answer](http://stackoverflow.com/questions/16849801/is-trying-to-develop-for-medium-trust-a-lost-cause). It also appears that the `[assembly: AllowPartiallyTrustedCallers]` attribute has been removed in MVC5 which is probably the cause of the exception in the html helper –  Aug 17 '14 at 08:00
  • 1
    MS have also stated in [known issues](http://www.asp.net/visual-studio/overview/2013/release-notes#knownissues) that _"ASP.NET MVC 5 no longer supports partial trust...."_ (perhaps time for a new hosting provider?) –  Aug 17 '14 at 08:08
  • Sigh, thanks. You're the first person who's been able to give me that reason. If you post that as an answer I'll mark it as the answer. – Mr_Bean Aug 17 '14 at 12:03
  • Possible duplicate of [Is trying to develop for Medium Trust a lost cause?](https://stackoverflow.com/questions/16849801/is-trying-to-develop-for-medium-trust-a-lost-cause) – Liam Aug 09 '17 at 09:00

1 Answers1

6

The current versions of ASP.NET now only support full trust. MS have stated in Release Notes: Known Issues that:

ASP.NET MVC 5 no longer supports partial trust....

In particular the [assembly: AllowPartiallyTrustedCallers] attribute has been removed from the source code. You can read more about ASP.NET's official position in Levi's answer to is-trying-to-develop-for-medium-trust-a-lost-cause, which also includes further links to why support has been removed.

Liam
  • 27,717
  • 28
  • 128
  • 190