Base solution for your next web application
Open Closed

Dynimac Web API cannot customzied namespace in asp.net core? #3084


User avatar
0
trendline created

ABP could Building Dynamic Web API Controllers and the namespace of the API could be customized in module initialize, but it seems this cannot be implemented in asp.net core integration, in asp.net core only below configuration available

Configuration.Modules.AbpAspNetCore().CreateControllersForAppServices(typeof(MyApplicationModule).Assembly, moduleName: 'app', useConventionalHttpVerbs: true)

This really not convenient, as I have lots of same name application service in different namespace in the application module.

Could you also make the Dynamic Web API controllers feature available for asp.net core?


4 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Actually, we don't suggest to use same application service name in different namespaces of a single module/assembly. That makes debugging harder for you too. But surely it's technically possible, it's your choice.

    Can you create a feature request (issue) on ABP framework: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate">https://github.com/aspnetboilerplate/aspnetboilerplate</a>

  • User Avatar
    0
    trendline created

    Yes,using same name application service in a module or assembly is not a good pattern, but sometimes it is required, such as a "Category" entity, it is a so common definition in different namespace, accordingly, "CategoryAppService" also will existing in different namespaces.

    Especially, in my project requirements, lots of similar entities are needed(because they need mapping to individual table in database), if each application service add the prefix will cause the application service and according DTO with long name, it is not convenient when coding.

    So I want to customize the API namespace like ABP.WebApi done.

    Another story, Swagger also not support same name application service(even they are polymorphism) and not support DTO with same name.

  • User Avatar
    0
    hikalkan created
    Support Team

    I think, even for Category, you should choose different names, like ProductCategory, UserCategory... etc. Otherwise, you frequently make mistakes in your code. Swagger probably also does not support it as you say. You can ask it to it's Github repository if there is a workaround.

  • User Avatar
    0
    hikalkan created
    Support Team

    BTW, ASP.NET MVC also does not support using same controller name in your solution by default.