Base solution for your next web application
Open Closed

[WebAPI] General problems with module zero #491


User avatar
0
silfm created

Hi!

I'am developing WebApi application based on module zero. In module class i have depends on: AbpWebApiModule, WebMeetDataModule, WebMeetApplicationModule. I have this problems:

  1. In Controllers dependency injection not working, my controller iherits from AbpApiController
  2. When I throws UserFriendlyException from Controller, this Exception is not handled. I have a <customErrors mode="On" /> in web.config.

Can anyone help me? Thanks


5 Answer(s)
  • User Avatar
    0
    silfm created

    Up!

  • User Avatar
    0
    hikalkan created
    Support Team

    Don't you have .Web project at all? How do you initialize ABP?

  • User Avatar
    0
    silfm created

    I don't have .Web project. My startup proejct is .Api. In this project i have class WebApiApplication which inherits AbpWebApplication. Also I have module class WebApiModule which inherits AbpModule and overrides PreInitialize and initialize.

    Code: WebApiApplication <a class="postlink" href="http://codepaste.net/hwhvrr">http://codepaste.net/hwhvrr</a> WebApiModule <a class="postlink" href="http://codepaste.net/hea4ji">http://codepaste.net/hea4ji</a>

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    You may need to HttpConfiguration.EnsureInitialized() call like that: <a class="postlink" href="https://github.com/aspnetboilerplate/sample-odata/blob/master/src/AbpODataDemo.WebHost/App_Start/AbpODataDemoWebModule.cs#L37">https://github.com/aspnetboilerplate/sa ... ule.cs#L37</a>

    Add this to your WebMeetWebApiModule:

    public override void PostInitialize()
            {
                Configuration.Modules.AbpWebApi().HttpConfiguration.EnsureInitialized();
            }
    

    Note: I hosted webapi in an empty web project in this example (<a class="postlink" href="https://github.com/aspnetboilerplate/sample-odata">https://github.com/aspnetboilerplate/sample-odata</a>).

  • User Avatar
    0
    silfm created

    I added this line but this still not working.

    I downloaded your odata project. How can I check routing? What is address to PersonController?