Hello,
I want to use a regulard Web API 2 project instead of the self-hosted project generated by the template. So i added a new web api 2 project to solution. I added the packe abp.web.api. I added the module class and the dependency
[DependsOn(
typeof(TestDataModule),
typeof(TestApplicationModule),
typeof(AbpWebMvcModule),
typeof(AbpWebApiModule))]
public class TestApiModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
DynamicApiControllerBuilder
.ForAll<IApplicationService>(typeof(TestApplicationModule).Assembly, "app")
.Build();
Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer"));
}
}
But when I tried to call directly a service from the application project, I have 404 not found error. When I tried to call directly a controller, I have the error : "An error occurred when trying to create a controller of type 'WhateverController'. Make sure that the controller has a parameterless public constructor."
It seems like an error related to the IoC mechanism.
Am I missing something? thanx
Hey there, I'm having the same issue in a mvc controller.
public ActionResult Grid_Read([DataSourceRequest] DataSourceRequest request)
{
var suppliers = GetAll();
return Json(suppliers.ToDataSourceResult(request));
}
[UnitOfWork]
public virtual IEnumerable<SupplierListOutput> GetAll()
{
return _supplierRepository.GetAll().ProjectTo<SupplierListOutput>();
}
I'm using kendo ui Grid component that can performs filtering, sorting, paging.... That's why I need to have a direct acces to the repository in my controller and pass a IQueryable variable in my action method .
But I stilll have the error : The operation cannot be completed because the DbContext has been disposed.
The repository is injected in the controller constructor
For those having the same issue, the solution is to set a Custom DataSource configuration. This will allow you to set a custom function for the schema.parse and return the appropriate portion of the response. For example:
@(Html.Kendo().Grid<MyModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(typeof(string), "column1");
columns.Bound(typeof(string), "column2");
})
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Custom()
.ServerFiltering(true)
.Type("aspnetmvc-ajax")
.Transport(transport =>
transport.Read(read => read.Action("action", "controller"))
)
.Schema(schema => schema
.Model(m=>m.Id("columId"))
.Parse(@<text>
function(response) {
return response.result;
}
</text>)
.Data("data")
.Total("total")
)
)
)
Be aware that if a property of you Model is "PropertyName" it will became "propertyName" in ajax response. so columns.Bound(p => p.PropertyName) wont' work.
Excellent. Thanks
I will follow you on twitter to be notify when there is a new version.
Hello,
I have the same problem. I can't find a way to use Kendo Grid.
@Klainer did u found a solution?
@hikalkan Is it possible to deactivate abp ajax wrapper?
Thank you.