Security Exception on ASP.NET MVC 5 site Related To Trust Level

Discussion in 'Site Programming, Development and Design' started by bobsoftware, Oct 9, 2018.

  1. Hello everyone.
    I am getting the following error on my MVC site, www.robertmarquez.com, after I added a web api service to it:

    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.

    I added the following to the web.config file as described on the tech support docs but it does not help:

    <system.web>
    <trust level="Full" />
    </system.web>

    What else can I do about this problem?
     
  2. ComputerMan

    ComputerMan Winhost Staff

    I visited your site and I didn't get the error message. How do we recreate the issue on our end?
     
  3. I rebuilt the site using a different Visual Studio template. It looks like there is a problem using the template that starts by selecting an MVC site then clicking the Web API checkbox. If I do that and simply try to run it I get errors. This is happening on Windows 10 using Visual Studio 2017. My solution was to rebuild the site using the MVC 5 template and not clicking the check box for for Web API. Then I manually created another folder at the root level of the site which I defined as an application folder with IIS. Then I created another visual studio project using only the Web API option. I then published the independent Web API project into the MVC web site application folder I created in the MVC project. It all works now allowing me to make calls to the Web API from the MVC 5 web site. I just thought I could get both types of projects into one using the MVC and Web API check boxes at creation time but it only caused problems.
     

Share This Page