Hi, I purchased an ASP.NET Zero project and have followed these instructions: <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/OData-Integration">http://aspnetboilerplate.com/Pages/Docu ... ntegration</a> to try OData with an entity ("Contact") I created, but when I try: GET: <a class="postlink" href="https://localhost:44305/odata/Contacts">https://localhost:44305/odata/Contacts</a> I only get the standard response "oops you're lost".
So I am wondering if the RouteConfig included in the ASP.NET Zero Web module applications is interfering with the automatic OData registration in the WebApi module.
Here is my Controller:
public class ContactsController : AbpODataEntityController<Contact, Guid>
{
public ContactsController(IRepository<Contact, Guid> repository)
: base(repository)
{
}
}
And here is my WebApi module:
/// <summary>
/// Web API layer of the application.
/// </summary>
[DependsOn(typeof(AbpWebApiODataModule), typeof(CosmosMoonApplicationModule))]
public class CosmosMoonWebApiModule : AbpModule
{
public override void PreInitialize()
{
var builder = Configuration.Modules.AbpWebApiOData().ODataModelBuilder;
//Configure OData entities here...
builder.EntitySet<Contact>("Contacts");
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
//Automatically creates Web API controllers for all application services of the application
DynamicApiControllerBuilder
.ForAll<IApplicationService>(typeof(CosmosMoonApplicationModule).Assembly, "app")
.Build();
Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer"));
}
public override void PostInitialize()
{
Configuration.Modules.AbpWebApi().HttpConfiguration.EnsureInitialized();
}
}
Any ideas? Thank you, RobertFitch
2 Answer(s)
-
0
Hi,
Thank you for pointing that. I found the problem. MVC default controller/action route conflict with odata route. I will make a fix for it in ABP 0.8. For now, as a workaround, move your Route code from Initialize of your WebModule to PostInitialize.
A working branch: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/commit/18f091274b9190e598bc6dc763866abafe9811a9">https://github.com/aspnetzero/aspnet-ze ... bafe9811a9</a>
NOTE: This is also valid for open source ABP templates.
-
0
Thanks for your quick help, the workaround is now running! regards