Deploying aspnet core api to desktop iis RRS feed

  • Question

  • User1063080413 posted

    I have a deployment issue with my aspnetcore 3.1 api project that I don't understand.
    Generally, run the aspnetcore project against IIS Express, then test it using postman.  

    It works in this configuration, however, if I attempt to run against my local iis, it fails on a database connection.
    I am running against my local instance of SqlServer.  Here is my api configuration:
      "iisSettings": {
        "windowsAuthentication": false,
        "anonymousAuthentication": true,
        "iis": {
          "applicationUrl": "http://localhost/MyAPIProject",
          "sslPort": 0
        "iisExpress": {
          "applicationUrl": "http://localhost:56232",
          "sslPort": 44319
      "$schema": "http://json.schemastore.org/launchsettings.json",
      "profiles": {
        "IIS Express": {
          "commandName": "IISExpress",
          "launchBrowser": true,
          "launchUrl": "api",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        "BeeTherrAPI": {
          "commandName": "IIS",
          "launchBrowser": true,
          "launchUrl": "api",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          "applicationUrl": "https://localhost:5001;http://localhost:5000"

    In both cases iis express and iis, I am running against the same db connection string:

    is there an issue with iis accessing a localdb connection string?

    Wednesday, December 9, 2020 12:37 AM


All replies

  • User1312693872 posted

    Hi Robotuner,

    When you run it on local iis, is there any error message?  And ensure your website’s domain account has permissions to access the database.

    Best regards,

    Jerry Cai

    Thursday, December 10, 2020 9:27 AM
  • User1063080413 posted

    Thanks Jerry.

    When I run against iis, I need to run VS with elevated credentials.
    there does not appear to be a problem starting the instance.
    Running under IIS Express, the site is https://localhost:44309/api
    Running under IIS Desktop, the site is https://localhost:45000/ProjectName/api

    The error message in postman is: connect ECONNREFUSED

    I will note that in the successful call to IIS Express the first two lines of the postman response is:
    GET https://localhost:44309/api/host
    Warnig: Unable to verify the first certificate

    I initially thought it was a cors issue but I added the following to my startup configure:
    app.UseCors(options => options.AllowAnyOrigin());

    but it makes no difference.

    the sql database in also local on my machine.  I would not think that there would be a dB permission problem,
    besides, the issue appears to be a connection to the website issue.

    Thursday, December 10, 2020 1:33 PM
  • User475983607 posted

    I follow the official ASP.NET Core deployment documentation.  Setup the IIS application according to the docs.  Then all you have to do is publish  to the application folder setup in IIS.  


    This is like having a dev and text environment on your local machine.  Development and debugging continues against the development source.  You have the ability to run the app in a hosted environment where you can test configuration.  This setup is also handy for developing code against REST services where the REST services are known to function as expected.  

    I typically use "dotnet run watch" to startup services during dev.  That way you can see exceptions and logs in the console.  The watch switch recompiles the code after making a change.  https://docs.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch?view=aspnetcore-5.0

    Thursday, December 10, 2020 2:31 PM
  • User1063080413 posted

    Thanks for you help.   I believe my environment was corrupt and I ended up deleting the .vs folder as described here:


    That didn't completely solve the issues, I finally went into the web.config folder and removed an environmentVariable the set the ssl port to 45000.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 11, 2020 3:08 PM