1

TLDR: selecting a profile with dotnet gives no errors, but just exits. Running it without a profile the app launches correctly, but does not listen on the ports I want.

I want to launch an existing asp.net site on Linux that always just worked on ms win.

When I launch the asp.net app with dotnet run, it will complain it cannot find Default profile, and it will launch the app sucessfully on ports 5000 and 5001.

When I lauch the app with dotnet run --launch-profile DevKestrel -v n it shows no failures and it builds successfully. It ends with this:

Using launch settings from /some/Some.Web/Properties/launchSettings.json...

and then it just exits there instead of keeping active and listing on ports 44328 and 44327.

In a fresh skeleton project made with dotnet new mvc -f netcoreapp3.1 the DevKestrel profile just works.

Besides some warnings like this, everything builds:

"Some.Web.csproj" (default target) (1:7) ->
       (ProcessFrameworkReferences target) -> 
         /usr/share/dotnet/sdk/3.1.120/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(39,5): warning NETSDK1086: A FrameworkReference for 'Microsoft.AspNetCore.App' was included in the project. This is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs

target framework: netcoreapp3.1

$ dotnet --version
3.1.120

$ dotnet --list-sdks 
3.1.120 [/usr/share/dotnet/sdk]
6.0.102 [/usr/share/dotnet/sdk]


launchSettings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
      "applicationUrl": "http://localhost/Some.Web",
      "sslPort": 0
    },
    "iisExpress": {
      "applicationUrl": "http://localhost:55814",
      "sslPort": 44328
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "profiles": {
    "DevKestrel": {
      "commandName": "Project",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:44328;http://localhost:44327",
      "environmentVariables": {
        "Environment": "Development",
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "Environment": "Development",
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
}

Program.cs


        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
           
            // START WEB HOST BUILDER
            var builder = WebHost.CreateDefaultBuilder(args)
                .UseIISIntegration()
                .UseStartup<Startup>()
                .ConfigureLogging(logging =>
                {
                    logging.ClearProviders();
                    logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
                })
                .UseNLog()// NLog: setup NLog for Dependency injection
                .ConfigureServices((hostContext, services) =>
                {
                    // add a singleton to host the ManagedTasks service
                    services.AddSingleton<IManagedTasks, ManagedTasks>();

                    // add a hosted service, which will kick off some scheduled tasks.
                    services.AddHostedService<TaskService>();
                    services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
                    services.AddControllers().AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize);
                });

            return builder;
        }

Startup.cs


public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    static readonly string _RequireAuthenticatedUserPolicy =
                        "RequireAuthenticatedUserPolicy";
    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        // Cookies
        /*
        services.Configure<CookiePolicyOptions>(options =>
        {
            // This lambda determines whether user consent for non-essential cookies is needed for a given request.
            options.CheckConsentNeeded = context => true;
            options.MinimumSameSitePolicy = SameSiteMode.None;
        });
        */

        services.Configure<KestrelServerOptions>(options =>
        {
            options.AllowSynchronousIO = true;
        });

        
        services.AddIdentityCore<IdentityUser>()
        
        services.AddSingleton<IConfiguration>(Configuration);

        services.AddHttpContextAccessor();
        
        services.AddOData();
#pragma warning disable CS0618 // Type or member is obsolete
        services.AddNodeServices(o =>
        {
            o.InvocationTimeoutMilliseconds = 100000;

        });
#pragma warning restore CS0618 // Type or member is obsolete

        // Model binder
        services.AddTransient<SignInManager<IdentityUser>>();
        services.AddMvc(options =>
        {
            options.ModelBinderProviders.Insert(0, new RecordModelBinderProvider());
            options.EnableEndpointRouting = false;
            //https://stackoverflow.com/questions/58986882/asyncenumerablereader-reached-the-configured-maximum-size-of-the-buffer-when-e
            options.MaxIAsyncEnumerableBufferLimit = 100000;

        })
        

        services.AddResponseCompression(options =>
        {
            options.EnableForHttps = true;
        });

        services.AddAuthorization();

        /*
        services.AddAuthorization(o => o.AddPolicy(_RequireAuthenticatedUserPolicy,
                    builder => {
                        builder.RequireAuthenticatedUser();
                        builder.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme);
                    }));
        */

        services.AddMvcCore(action => action.EnableEndpointRouting = false);
        services.Configure<IISServerOptions>(options =>
        {
            options.AllowSynchronousIO = true;
        });

    }
}
Exception e
  • 1,864
  • 3
  • 19
  • 33

0 Answers0