-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MapControllers has no effect? #38672
Comments
Likely a dupe of #7315. #7315 (comment) has a workaround. Could you give it a try and see it addresses your issue? |
Hi @mmisztal1980. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@pranavkm I've added a commit to reflect the comment from #7315 and it started working as described. Given the problem appears to be related to the @davidfowl & @pranavkm is it possible to compose the processing pipeline without the
|
You can use |
Hi @davidfowl , thanks for your suggestion. Do you feel this will be a viable workaround? Edit I've updated my sample to reflect the latest discussion. It appears that the sample is not working at all at the moment, even when applying the workaround from the original thread. Any suggestions what can be done here? private IHost CreateHostBuilder(IConfigurationRoot configuration = null, params string[] args)
{
var host = global::Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseConsoleLifetime()
.ConfigureAppConfiguration((cfg) =>
{
if (configuration != null)
{
cfg.AddConfiguration(configuration);
}
else
{
cfg
.AddJsonFile("appsettings.json", optional: false)
.AddEnvironmentVariables()
.AddCommandLine(args);
}
})
.ConfigureServices(services => {
services.AddAuthorization();
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "net6ihost", Version = "v1" });
});
services.AddMiddlewareAnalysis();
})
.ConfigureWebHostDefaults(host =>
{
host.UseSetting(WebHostDefaults.ApplicationKey, Assembly.GetEntryAssembly().FullName);
host.Configure(app =>
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "net6ihost v1"));
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
});
//app.UseStartup<Startup>();
// https://github.com/dotnet/aspnetcore/issues/7315#issuecomment-482458078
//app.UseSetting(WebHostDefaults.ApplicationKey, Assembly.GetEntryAssembly().FullName);
})
.Build();
return host;
} |
@davidfowl has provided a fix for the Again, thank you for spending time on this. |
As a part of a pet-project, I'm working on a mini-framework to rapidly prototype ready to use asp.net core services which:
IHost
instead ofWebApplication
b/c I need more control over my app than the WebApplication provides (such as support forCancellationToken
inRunAsync
as I like to start/stop my service instances in integration testsOne of the service "modes" is "Api Controller".
In this case the service is expected to be configured in the same way as a minimalistic dotnet template which uses ASP.NET Core Controllers & Open API support. In order for this to happen, the service needs to :
services.AddAuthorization()
services.AddControllers()
Describe the bug
The service starts properly, however:
/swagger
endpoint does not indicate any other endpoints are present/weatherforecast
endpoint returns a 404To Reproduce
I've managed to create a minimalistic repro project located here which is consistently failing on my Windows and MacOS machines.
6.0.100
Repro.ApiControllers.Demo
Repro.ApiControllers.Demo
/weatherforecast
(404 will be returned)Exceptions (if any)
None. I suspect it's either an interesting issue or a really stupid bug, however I haven't been able to spot this for the past couple of evenings.
Further technical details
dotnet --info
:dotnet --info Output
The text was updated successfully, but these errors were encountered: