ASP.NET core program without publishing to IIS

I used asp.net mvc4 and pointed my solution catalog to my location on the IIS site, every time I update my code, I just click on rebuild my solution and then use the "Attach to process" w3wp.

In asp.net core, when I published my site on the file system, I can start my site using iis without managed code. But when I point my iis site to my website solution code, it shows error 502. All asp.net kernel modules that I previously installed.

+4
source share
3 answers

The simple answer : when publishing, you call the script, run the tool publish-iis(see section scriptc project.json).


In your project, you have a file web.configwith something like this:

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" 
 stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/

As you can see, there are placeholder options "%LAUNCHER_PATH%"and %LAUNCHER_ARGS%. Keep this in mind.

Now open the project.json file and you will see the "scripts" section looking +/- as follows:

Scripts: {"postpublish": "dotnet publish-iis --publish-folder% publish: OutputPath% --framework% publish: FullTargetFramework%"}

It tells dotnet to start the publish-iis tool after publishing the application. How it works :

Publish-iis tool

, ( ), , web.config. . , , (.. CLR Core CLR - Core CLR - ) processPath % LAUNCHER_PATH% % LAUNCHER_ARGS% .

+1

.Net Core IIS, .., , .

.Net Core "dotnet run"

DotNet Run , . , , URL- , Type:

SET ASPNETCORE_URLS=http://example.com

, ,

SET ASPNETCORE_URLS=http://localhost:8080

SET ASPNETCORE_ENVIRONMENT=Development

, ,

dotnet run

, , cmd.exe dotnet Title. .

, Visual Studio "launchSettings.JSON". , , Kestrel Development, Kestrel Production, IIS , F5 IIS Express.

My LaunchSettings.json :

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:56545/",
      "sslPort": 0
    }
  },
  "profiles": {
    "Kestrel Development": {
      "executablePath": "dotnet run",
      "commandName": "Project",
      "commandLineArgs": "dotnet run",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_URLS": "http://localhost:8080"
      }
    },
    "Kestrel Production": {
      "commandLineArgs": "dotnet run",
      "commandName": "Project",
      "environmentVariables": {
        "ASPNETCORE_URLS": "http://localhost:8080",
        "ASPNETCORE_ENVIRONMENT": "Production"
      },
      "executablePath": "dotnet"
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

- , F5 , . , F5, Visual Studio dotnet URLS, environmentVariables launchSettings.JSON.

, , , Kestrel Production, .

enter image description here

+3

Ctrl + F5, , .

-2

Source: https://habr.com/ru/post/1650996/


All Articles