Skip to content

Restart application gives HttpSysException The prefix is already registered #60107

Open
@rgroenewoudt

Description

@rgroenewoudt

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I would like to start and stop our application on demand, without exiting the process. Code would be similar like:

 var builder = WebApplication.CreateBuilder(args);

 builder.WebHost.UseHttpSys();
 builder.Services.AddControllers();

 var app = builder.Build();

 await app.StartAsync();
 await app.StopAsync();

// Something here

 await app.StartAsync();

However, with http.sys this gives an exception: Microsoft.AspNetCore.Server.HttpSys.HttpSysException: 'The prefix 'http://localhost:5074/' is already registered.'.

Minimum testcase: WebApplication2.zip

Is there any way to restart the app or a workaround to make this work?

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

9.0.102

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions