MapleStory MapleStory - 1 year ago 130
ASP.NET (C#) Question

ASP.NET Core Program running without publish on IIS

I used to use the mvc4 and point my solution directory to my IIS website location,every time I update my code ,I just click the re-build my solution and then using the "Attach to process" of w3wp.

In core;When I published my website to file system ,I can run my website using iis with no-managed code.But when I point my iis Website to my solution code of website ,it shows 502 error. All modules of core I had installed before.

Set Set
Answer Source

Simple answer: when you do publish, you call script that launch publish-iis tool (see script section in project.json).

In your project you have web.config file with the something like this:

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

As you see, there are placeholders "%LAUNCHER_PATH%" and %LAUNCHER_ARGS% parameters. Keep in mind this.

Now open open your project.json file and you will see a "scripts" section looking +/- like this:

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

It tells dotnet to run the publish-iis tool after the application is published. How it works:

publish-iis tool goes to the folder where the application was published (not your project folder) and checks if it contains a web.config file. If it doesn’t it will create one. If it does it will check what kind of application you have (i.e. whether it is targeting full CLR or Core CLR and – for Core CLR – whether it is a portable or standalone application) and will set the values of the processPath and arguments attributes removing %LAUNCHER_PATH% and %LAUNCHER_ARGS% placeholders on the way.