1

I want build a solution with two listening entry points with partly the same paths but different purposes and responses. Therefore I've followed the introductions on https://khalidabuhakmeh.com/hosting-two-aspnet-core-apps-in-one-host strictly - used different ports for both "startups" and so on. Unfortunately the running environment fails by calling a double existing path with an appropriate port. The startup file, controllers and further configuration of the second entry point are in an additional project.

public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });

        public static IHostBuilder CreateSecondBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseUrls("http://*:5500").UseStartup<SecondEndpoint.Startup>();

                });

The error message is

Connection id "xxx",, Request id "xxx": An unhandled exception was thrown by the application. Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches: Controllers.FruitsController.GetFruits (...) SecondEndpoint.Controllers.FruitsController.GetFruits (...)

In my opinion, the fault is that

app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });

maps all Controllers of all referenced projects. Is their a possibility to adjust the mapping of some controllers to a specific entr ypoint?

0

1 Answer 1

-1

I was able to solve this issue by using solution given in this link.

Check this Add/Skip ApiController for Web API in .Net Core

essentially you have to map only the required controller for each startup class in configure service method.

Sign up to request clarification or add additional context in comments.

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
If you think another post answers this question, please flag this question as a duplicate instead of posting an answer linking to that other post.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.