locked
I know that in deploying a Core 2 App to IIS of a production server, a web.config file is created. How can I edit it on the development side? RRS feed

  • Question

  • User-858993849 posted

    I am trying to deploy a core 2 app to IIS on a production server (Windows Server 2012 R2), but also want to be able to edit and control the web.conf file that is automatically created when publishing the app.  I have published it, but can't get it to run.

    I did the following to try to get a Core 2 app running on the production server.

    Added ".UseIISIntegration()" to the WebHost.CreateDefaultBuilder(args) in the program.cs file.

    On IIS of the production server, I created a new Application pool choosing "No Managed Code" as the .Net CLR Version.

    Published the app to the production server, but I get nothing, without errors, but it does not go to the default document and just loads the default IIS page.

    What am I doing wrong?

    Saturday, March 17, 2018 3:57 PM

Answers

  • User283571144 posted

    Hi JAYHAWKER,

    As far as I know, the auto generated web config file is used to tell the iis to start the application from asp.net core module. 

    The config as below:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath="dotnet" arguments=".\Asp.netCoreTest.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
      </system.webServer>
    </configuration>
    <!--ProjectGuid: 98be057e-027d-4191-b586-f02dd64ae5b6-->

    I suggest you could firstly check your application and make sure you have set the right route config.

            public void Configure(IApplicationBuilder app, IHostingEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                    app.UseBrowserLink();
                }
                else
                {
                    app.UseExceptionHandler("/Error");
                }
    
                app.UseStaticFiles();
    
                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller}/{action=Index}/{id?}");
                });
            }

    Besides, I guess you may not install the net core SDK on your server-side.

    I suggest you could try to install it and run your application again.

    https://www.microsoft.com/net/download/windows 

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 19, 2018 8:31 AM

All replies

  • User283571144 posted

    Hi JAYHAWKER,

    As far as I know, the auto generated web config file is used to tell the iis to start the application from asp.net core module. 

    The config as below:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath="dotnet" arguments=".\Asp.netCoreTest.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
      </system.webServer>
    </configuration>
    <!--ProjectGuid: 98be057e-027d-4191-b586-f02dd64ae5b6-->

    I suggest you could firstly check your application and make sure you have set the right route config.

            public void Configure(IApplicationBuilder app, IHostingEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                    app.UseBrowserLink();
                }
                else
                {
                    app.UseExceptionHandler("/Error");
                }
    
                app.UseStaticFiles();
    
                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller}/{action=Index}/{id?}");
                });
            }

    Besides, I guess you may not install the net core SDK on your server-side.

    I suggest you could try to install it and run your application again.

    https://www.microsoft.com/net/download/windows 

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 19, 2018 8:31 AM
  • User-858993849 posted

    I actually discovered that you can go ahead and create web.config file on the development side, and then it will automatically be used on the production server. It will only create it for IIS if it doesn't already exist.

    Thanks for your efforts.

    Monday, March 19, 2018 12:54 PM