Can't connect to Nop.Web after importing database

5 months ago
Hi All,
With my development site running well on my local server with Nop 4.60, I imported all my old data from my previous site which was v3.80. Now when I try to run it I get the error "Unable to connect to web server 'Nop.Web'" and "Web server failed to listen on port 5001". I am running VS 2022. Has the import of old data into the datbase changed any settings? Or, has updating to the latest version of VS 2022, which is the only other thing I did, changed something? The appsettings.json file looks OK, as does LaunchSettings.json.
Any help appreciated.
Thanks
5 months ago
I suggest you rename your appsettings file so that you can see if the web app starts without a DB.
\Presentation\Nop.Web\App_Data\appsettings.json
I.e., the web will run and you should see the Install page.

(If you do want to run/test a new install to a new DB, then also rename your plugins.json in same folder)
5 months ago
Thanks for the reply. Unfortunately, I got the same result after renaming appsettings.json. The new appsettings.json still show the data provider as sqlserver.

"ConnectionStrings": {
   "ConnectionString": "",
   "DataProvider": "sqlserver",
   "SQLCommandTimeout": null

Also,  Launchsettings.json is specifying localhost:5001, which is what won't connect:

"Nop.Web": {
  "commandName": "Project",
  "launchBrowser": true,
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  },
  "applicationUrl": "https://localhost:5001;http://localhost:5000"
}
5 months ago
Carrolup wrote:
...,  Launchsettings.json is specifying localhost:5001, which is what won't connect...


That seems unusual for running in VS.  I typically see ports in a much higher range when I run in VS.  E.g.,

"applicationUrl": "https://localhost:55104;http://localhost:55105"
5 months ago
Try replacing your launchSettings.json file with the following one:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:65283/",
      "sslPort": 44369
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Nop.Web": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:5001;http://localhost:5000"
    }
  }
}


If it doesn't help, try changing your port number (see this post)
5 months ago
I tried re-installing SQL Express, but that didn't help. Debug shows it to be a login error to the database:

Microsoft.Data.SqlClient.SqlException
  HResult=0x80131904
  Message=Cannot open database "********" requested by the login. The login failed.
Login failed for user '******\*****'.
  Source=Core Microsoft SqlClient Data Provider

It must have something to do with me replacing the test database with the one from my live web site based on Nop 3.80, but I am not sure where I can find the login details. The dubug result came from Nop.Data.NopDbStartup