0

I hosted .NET Core Web API in local IIS following these steps:

  • Published the project into a file/folder location
  • In IIS Manager, mapped the folder location

When I browse the site from IIS, it shows the default "WeatherForecast" (sample .NET model) fine. But, when I try to browse my developed page/controller it shows nothing. Please note that, I am using datasource of SQL Server (locally) and using EF Core database first approach as ORM, and running from Visual Studio everything works fine.

I think, I need to point out my datasource anywhere during hosting in IIS.

I tried to use connection string in appsettings.json like below, but it didn't work

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "ConnectionStrings": {
    "DBConnectionString": "Server=.\\SQLEXPRESS;Database=TourActivityExpense;Trusted_Connection=True; User ID=sa; Password=sa123;"
  },
  "AllowedHosts": "*"
}
Dale K
  • 25,246
  • 15
  • 42
  • 71
BlackCat
  • 1,932
  • 3
  • 19
  • 47
  • 3
    Your connection string doesn't make sense; if you are using a trusted connection, then why do you define a user and password in it (and *why* is that user the `sa`)? – Thom A Jun 24 '22 at 08:43
  • `Trusted_Connection=True` and `User ID` are mutually exclusive, the former uses Windows Authentication (no username and password, it uses the IIS app pool user) the latter uses SQL Authetication (`sa` is an SQL Authentication login) so you need to remove `Trusted_Connection` – Charlieface Jun 24 '22 at 08:57
  • Done, but it still not showing – BlackCat Jun 24 '22 at 09:02

0 Answers0