0

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?

Community
  • 1
  • 1
Guruprasad J Rao
  • 29,410
  • 14
  • 101
  • 200

2 Answers2

2

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>
Guruprasad J Rao
  • 29,410
  • 14
  • 101
  • 200
  • I've tried that possibility too buddy! :( I'll get the same error!! – Guruprasad J Rao Jul 07 '15 at 07:24
  • before that you need to remove trust level=full – Laxman Parmar Jul 07 '15 at 07:37
  • In my case its MVC and I will be having `.cshtml` files instead of `.aspx` which will be inside views! Any idea how to give default document for MVC? – Guruprasad J Rao Jul 07 '15 at 07:43
  • routes.MapRoute( "Default", // Route name "", // URL with parameters new { controller = "Home", action = "Index"} // Parameter defaults ); – Laxman Parmar Jul 07 '15 at 07:48
  • that is already there!! Everything is fine and works well in localhost!! Its some server configuration problem and I am not really getting what it is!! – Guruprasad J Rao Jul 07 '15 at 07:49
  • 1
    I have also get this error in asp.net with three tier but after adding this the code shown in link i was enabled to perfect view on server following is the link https://help.1and1.com/hosting-c37630/scripts-and-programming-languages-c85099/aspnet-c39624/explanation-of-security-exception-error-a611691.html – Laxman Parmar Jul 07 '15 at 07:52
  • That was helpful to catch the proper error!! Let me try and let you know once I fix and publish it again.. +1 for efforts.. :) – Guruprasad J Rao Jul 07 '15 at 08:07
  • ! Thank you sou much! I am accepting your because of the link you have given! I'll edit your answer and update the same with the link. Thanks once again!! – Guruprasad J Rao Jul 08 '15 at 04:25
1

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

Soori
  • 61
  • 5
  • _At the moment you write this_? What you write? I'll try your suggestion of downgrading to MVC4. – Guruprasad J Rao Jul 07 '15 at 12:18
  • 1
    "At the moment I write this" is referring to asp.net mvc5 is not supported by plesk hostgator, but it may be or will be supported in future. – Soori Jul 08 '15 at 03:58