PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 16, 2022

[FIXED] How to deploy ASP.Net MVC 5 code from Visual Studio to GoDaddy Plesk Server- Code First

 July 16, 2022     asp.net-mvc, asp.net-mvc-5, c#, deployment, web-deployment     No comments   

Issue

Ok, I am a beginner and trying to deploy a web application in ASP.Net MVC 5 application in C# language developed using Code First Migration at godaddy server. I am completely surprised and disappointed to see that no proper material is available online to guide a beginner to deploy the app. Anyways after googling for a while I followed below steps and still not able to see my web app LIVE:

Step 1: Bought a domain name

Step 2: Bought a Plesk Server

Step 3: Linked the domain name to Plesk Server

Step 4: Now Went to plesk server settings and Downloaded the Publish Profile

Step 5: Now in Visual Studio I right clicked on solution and clicked on "Publish"

Step 6: Imported the downloaded publish profile, and Selected Web Deploy in Connection tab and Validated the connection to the server. Password is for the Plesk Server.

Step 7: Now I saw many checkboxes in the Settings tab, I chose options shown in the screenshot.

Image 1:

enter image description here

Image 2:

enter image description here

ASSUMING Above Setting is CORRECT which I am not SURE.

After Successful Publish I get below Error when I open the web app:

Error 1:

System.Security.SecurityException: Request failed

After searching on Internet I found I need to add

<trust level="Full"/> 

in my Web.Config FIle. So, in my local VS I made change to Web.Config file like below:

  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
    <customErrors mode="Off"/>
    <trust level="Full" />
  </system.web>

Moving On, Now again I published the app and Now I see below error:

Error 2:

System.ComponentModel.Win32Exception: This program is blocked by group policy. For more information, contact your system administrator

Now again I searched google and found out that I need to Tick Mark the "enable precompiling the website"

Image 3:

enter image description here

Now after all this When I run the application I get below error:

Image 4:

enter image description here

P.S: I logged in to Plesk Server and I can see my project files got uploaded to the server. Can someone guide me on what is the issue. Have I made any mistakes in WEB DEPLOY SETTINGS, Or Web.Config or even Connection String?


Solution

Ok after much struggle I was able to find the solution. Below is what I did.

Step 1: Follow all the steps mentioned in the question.

Step 2: If you are developing the application with SSL Enabled, Kindly disable it for the time being, by going to the property of the Solution.

Step 3: Now check your FilterConfig.cs file and make sure YOU DO NOT HAVE below line of code.

filters.Add(new RequireHttpsAttribute()); // COMMENT THIS LINE

Step 4: Now go to plesk Server, Create a Database. Give it a User.

Step 5: In Asp.Net Settiings, Create a connection string Data Source=184.XXX.XX.X,1433;Network Library =DBMSSOCN;Initial Catalog=GIVEHEREDATABASENAME;User ID=DBUSERNAME;Password=DBUSERPASSWORD;

Step 6: Now go to ASP.Net Settings, from there Copy the Default Connection String.

Step 7: Now while deploying the project paste this connection string in the Connection String section in VS.

Step 8: Click Publish and you should be all set.



Answered By - Unbreakable
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing