question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configuring DynamicApiControllerBuilder

See original GitHub issue

Hi All,

I’m trying to setup an application from ASP.NET Boilerplate Templates. I’ve chosen ASP.NET Core 1.0 which is not actually pure ASP.NET Core because it uses .Net Framework 4.6.1. An app which is just installed works fine, however, I want to replace ASP.NET MVC with ASP.NET WebAPI. Any of my attempts led me to error 404. Please advise, what am I doing wrong?

My changes were:

  • Extending of Application layer with a trivial Service.
public interface IAccountAppService : IApplicationService
{
    Task<string> GetAllAccounts();
}

public class AccountAppService : CrmAppServiceBase, IAccountAppService
{
    public async Task<string> GetAllAccounts()
    {
        return await Task.Run(() => "Hello world!");
    }
}
  • Adding a reference to the Abp.Web.Api package for the Crm.Web project.
  • Updating the PreInitialize() method like as below:
public override void PreInitialize()
{
    Configuration.DefaultNameOrConnectionString = _appConfiguration.GetConnectionString(CrmConsts.ConnectionStringName);

    Configuration.Navigation.Providers.Add<CrmNavigationProvider>();

    Configuration.Modules.AbpAspNetCore()
        .CreateControllersForAppServices(
            typeof(CrmApplicationModule).Assembly
        );

    DynamicApiControllerBuilder
        .ForAll<IApplicationService>(Assembly.GetAssembly(typeof(CrmApplicationModule)), "crm")
        .WithConventionalVerbs()
        .Build();
}
  • Running the application and trying to access Api action by navigating to http://localhost:62114/api/services/crm/account/GetAllAccounts

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
not-authorizedcommented, Aug 17, 2016

I had just to use

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

instead of

DynamicApiControllerBuilder
   .ForAll<IApplicationService>(typeof(TagCrmApplicationModule).Assembly, "crm")
   .Build();

since I’m using ASP.NET Core project.

Thanks!

0reactions
hikalkancommented, Aug 17, 2016

Yes, AspNet Core replaces all of them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building Dynamic Web API Controllers
This configuration should be made in the Initialize method of your module. ... DynamicApiControllerBuilder provides a method to build web api controllers ...
Read more >
Building Dynamic Web API Controllers
In this code, we created dynamic web api controllers for all application services in an assembly. Then overrided configuration for a single application ......
Read more >
Dynamic Web API Controllers and WithConventionalVerbs()
I'm using Dynamic Web API Controllers but my Get methods are being ... Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder .
Read more >
How to configure dynamic API for multiple module #2063
Hello dears We are building a project that we want to have in modules. Like a module for 'blog', 'sales', 'accounting', .
Read more >
Using boilerplate with a REST api #2623
Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder.For("tasksystem/task").Build();. Is that it or is there anything else I need ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found