locked
Asp.Net Core 2.2 targeting IIS and Linux RRS feed

  • Question

  • User718448626 posted

    I would like to know if it is possible to create a ASP.Net Core API project that can target IIS in-process as well as Linux (krestel) ? Thank you.

    Friday, August 9, 2019 8:13 AM

Answers

  • User711641945 posted

    Hi Albertk89,

    By adding the suggested configuration will the compiled dll still works on a Linux distribution as well as on Windows IIS? 

    It is just the way about how to publish to IIS with the configuration in Startup.cs.

    Before .net core 2.1, you are no need to change anything and publish them both.

    For .net core 2.2,you need to change the .csproj file to choose In-process hosting model or Out-of-process hosting model(Default is In-process).Then you could publish.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2019 10:17 AM

All replies

  • User753101303 posted

    Hi,

    I don't see why you couldn't. This is the whole purpose of ASP.NET Core. Be explicit if you ran into a problem.

    Edit: your concern is changing this option as needed in your project file? Never tried but a web.config transformation or even configuring this as a default at the IIS server level should be possible. Or if I remember using ASP.NET Core over  the NET 4.x framework doesn't support this (but I never really understood why you would do that rather than just taking the red pill).

    Friday, August 9, 2019 9:43 AM
  • User-1038772411 posted

    Hello, Albertk89

    it is very long process and easily we can get steps over internet. dont know what kind of problem you excectly facing but i am providing you reference link which gives you full idea regarding asp.net core and its deploy over iis processes.

    https://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core-Hosting-on-IIS-with-ASPNET-Core-22

    Thanks

    Friday, August 9, 2019 9:51 AM
  • User-474980206 posted
    Yes. It’s just the publish type chosen. Publish to a folder will support both.
    Friday, August 9, 2019 2:52 PM
  • User718448626 posted

    does it mean I that I can have one project that targets both?.   What are the changes needed for in startup.cs to support IIS in-process mode and does that affect the target for krestel ?  Thank you.

    Saturday, August 10, 2019 12:12 AM
  • User711641945 posted

    Hi Albertk89,

    What are the changes needed for in startup.cs to support IIS in-process mode

    For IIS,In-process hosting model,you need to configure like below:

    services.Configure<IISServerOptions>(options => 
    {
        options.AutomaticAuthentication = false;
    });

    Out-of-process hosting model,you need to configure like below:

    services.Configure<IISOptions>(options => 
    {
        options.ForwardClientCertificate = false;
    });

    Any more details about how to publish to IIS and Linux,You could refer to:

    https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2

    https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-2.2

    https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.2

    Best Regards,

    Rena

    Monday, August 12, 2019 9:01 AM
  • User718448626 posted

    By adding the suggested configuration will the compiled dll still works on a Linux distribution as well as on Windows IIS?   

    Monday, August 12, 2019 9:04 AM
  • User711641945 posted

    Hi Albertk89,

    By adding the suggested configuration will the compiled dll still works on a Linux distribution as well as on Windows IIS? 

    It is just the way about how to publish to IIS with the configuration in Startup.cs.

    Before .net core 2.1, you are no need to change anything and publish them both.

    For .net core 2.2,you need to change the .csproj file to choose In-process hosting model or Out-of-process hosting model(Default is In-process).Then you could publish.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2019 10:17 AM
  • User-474980206 posted

    you need to understand the configurations. forward headers, is used when your site runs behind a proxy (IIS is out of process, nginx or apache). If your are using windows authentication (IIS only), then you need credentials forwards.

    you can easily use app settings to control this configs at runtime, though you app is probably either windows authentication or not. you can turn on header forwarding even if not behind a proxy.

    the project setting for in process vs out of process just controls the web.config settings on publish, which are not used on linux, so it does not matter how you set the project.

    Monday, August 12, 2019 3:20 PM