skip to Main Content

I hosted my MVC website in plesk by using FTP publish option of VS2013 and everything went fine, I mean all the required files were copied properly in the destination under httpdocs virtual directory. But I am getting below error now when I visit the URL:

Server Error

I have tried all the possible solutions mentioned in many links but no proper solution I have got so for! Its making me real confusing about this!

I have tried to apply solutions in this and also checked this question but none of them were useful. My web.config file is as below:

<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=sometoken" requirePermission="false" />
  </configSections>
  <appSettings>
    <!--<add key="MaintenanceMode" value="false" />-->
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="SessionTimeoutRedirect" value="true" />
    <add key="isAjaxHandled" value="false" />
  </appSettings>
  <system.web>
    <customErrors mode="Off" />
    <trust level="Full"/>
    <compilation targetFramework="4.0" defaultLanguage="c#"/>
    <httpRuntime executionTimeout="1048576" maxRequestLength="100000" />
    <globalization culture="en-IN" uiCulture="en-IN" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" defaultUrl="~/Admin/Index" timeout="2880" protection="Encryption" slidingExpiration="true" cookieless="AutoDetect" />
    </authentication>
    <pages controlRenderingCompatibilityVersion="4.0" />
  </system.web>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="MCBConnectionString" connectionString="metadata=res://*/Models.EntityDataModel.MCBEntityModel.csdl|res://*/Models.EntityDataModel.MCBEntityModel.ssdl|res://*/Models.EntityDataModel.MCBEntityModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=somesource;Network Library=;Packet Size=4096;Integrated Security=no;User ID=uid;Password=pwd;Encrypt=yes;TrustServerCertificate=True; integrated security=no;connect timeout=120;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

Below is the file structure in Plesk Admin panel

enter image description here

One more thing to note: If I remove <trust level="Full"/> tag from web.config I will not get any error but no display too. A blank page will be shown

Am really confused about this! I am left with no other alternatives except to approach this forum now! Any experts out there who faced this issue or anything I have to configure more on web.config?

2

Answers


  1. Place The below code

    <compilation debug="true" targetFramework="4.0">

    instead of

    <compilation targetFramework="4.0" defaultLanguage="c#"/>
    

    hope it’s works

    This Link actually helps you to identify any sort of issues if it is not displayed in the server and thus I [OP] was able to fix my problem by identifying the issue.

    Below is what the link contains:

    When using ASP.NET, you may encounter the following error: “Security
    Exception” “Exception Details: System.Security.SecurityException:
    Security error.”

    This means a class during runtime is linked against a restricted
    class. By default ASP.NET error messages are optimized for
    compile-time and run-time errors only. So the real error sources are
    not displayed for linked errors. These errors arise for example, if
    you try to access registry variables or system variables etc.
    Sometimes you can get detailed error messages by placing the following
    code in global.asax file.

    <%@ Application %> 
    
    <script runat="server" language="c#">
    protected void Application_Error(Object sender, EventArgs e){
    Exception ex = Server.GetLastError();
    Server.ClearError();
    
    Response.Write("<pre>");
    Response.Write(Environment.NewLine);
    Response.Write("Caught Exception: " + ex.ToString() + Environment.NewLine);
    
    if (ex.InnerException != null){
    Response.Write(Environment.NewLine);
    Response.Write("Inner Exception: " + ex.InnerException.ToString() + Environment.NewLine);
    Response.Write(Environment.NewLine);
    }
    
    System.Security.SecurityException ex_security = ex as System.Security.SecurityException;
    
    if (ex_security != null){
    Response.Write(Environment.NewLine);
    Response.Write("Security Exception Details:");
    Response.Write(Environment.NewLine);
    Response.Write("===========================");
    Response.Write(Environment.NewLine);
    Response.Write("PermissionState: " + ex_security.PermissionState + Environment.NewLine);
    Response.Write("PermissionType: " + ex_security.PermissionType + Environment.NewLine);
    Response.Write("RefusedSet: " + ex_security.RefusedSet + Environment.NewLine);
    }
    
    Response.Write("</pre>");
    }
    </script>
    
    Login or Signup to reply.
  2. If you are using asp.net mvc5, it needs full trust, which is not supported by plesk (host gator) at the moment I write this.

    If that is the case you need to downgrade to mvc4 or find another hosting provider which supports full trust

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search