4

When I am using

<trust level="Full"/>

in Web.Config it gives error:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using from an inherited configuration file.

But When I skip trust level, it gives error

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.

I had also added [assembly: AllowPartiallyTrustedCallers] in AssemblyInfo.cs, but it could not help.

Any Help will be great.

My Web.Config:

   <?xml version="1.0" encoding="utf-8"?>
<!--

<configuration>
<configSections>

     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
   </configSections>
  <connectionStrings>

        // Here is my connection string
    </connectionStrings>
  <appSettings>
 <add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
 </appSettings>



   <system.web>

 <customErrors mode="Off"/>


  <compilation debug="true" targetFramework="4.0" />
  <authentication mode="Forms">
   <forms loginUrl="~/Account/Login" timeout="2880" />
  </authentication>
  <membership>
  <providers>
    <clear/>
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
         enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
         maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
         applicationName="/" />
  </providers>
</membership>

<profile>
  <providers>
    <clear/>
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
  </providers>
</profile>

<roleManager enabled="false">
  <providers>
    <clear/>
    <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
  </providers>
  </roleManager>


   <pages>
    <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
    </namespaces>
   </pages>


  </system.web>

<system.webServer>
manraj
  • 151
  • 7
  • Its on Online Server. Its not on local – manraj Dec 08 '15 at 11:05
  • This post identified why such error happened and how to overcome it [Security Exception](http://stackoverflow.com/questions/29742550/web-config-configuration-error-in-app) – Suprabhat Biswal Dec 08 '15 at 11:15
  • Removing trust level not solving my problem. – manraj Dec 08 '15 at 11:20
  • *Its on Online Server. Its not on local*, eh? that question is talking about IIS, this is online. You need alter the configuration of IIS, it's not set up correctly. i.e. [do this](http://stackoverflow.com/a/12867753/542251) – Liam Dec 08 '15 at 11:22
  • Contact the server administrator. He's the one who probably set the Security Level too low. – ZippyV Dec 12 '15 at 12:52

0 Answers0