An Update On My ASP.NET Core Project

My previous post reviewed over utilizing ASP.NET Core to create a Web API endpoint. In that post, I stated that there was nothing as of that writing that prevented me from continuing the usage of ASP.NET Core and .NET Core. However, as time went on, it was decided to use OData. This is where my roadblock appeared. As of the writing of this post, OData support does not currently exist for ASP.NET Core. I’ve got a separate project that didn’t make sense to use OData, so we’re going with ASP/.NET Core for that project. I’m pretty excited about that, considering all the benefits I’d talked about in my previous post.

For those unfamiliar, OData (Open Data Protocol) is a standard that defines how to build and utilize RESTful APIs. This standard is utilized in the .NET world via the Microsoft.Data.OData Nuget package, and can be utilized in an ASP.NET project using the Microsoft.AspNet.OData Nuget package (both described in more detail here). With OData, a client can specify what data they would like returned via a query string or other parameter. This in turn is translated into a specific query that only returns the specified dataset. This is very useful for minimizing data traffic and ensuring the client gets what they need.

For the project in question, we had a project returning JSON data with multiple fields and child objects. The total payload, including all objects and fields, was over 600MB. For a mobile experience, this would be unacceptable. There would also be multiple clients requesting different pieces of this data at any given time. While the clients could receive the full payload, and just ignore the fields and objects they don’t need, this is a waste of traffic. I could also create different endpoints for each need, but that could become difficult to manage over time as more needs arise. OData gave us the opportunity to specify a generic endpoint, and allow the client to decide what data they receive.

Looking into OData support for ASP/.NET Core, I found nothing. Looking deeper into the documentation, I found the RESTier project. At face value, this seems to be utilizing a more ASP.NET Core approach to creating an OData endpoint. However, it is also not supported for ASP/.NET Core at this time. Perhaps some time in the future, this may change.

In the meantime, I’ve pulled that project over to a full .NET 4.6.2 and AspNet.Mvc 5.2.3 project. That process was not too difficult; I created a new ASP.NET MVC project, added the existing files to it, switched IActionResults to IHttpActionResults, changed NoContent() results to StatusCode(HttpStatusCode.NoContent) results, and swapped out the Core Nuget packages for full .NET packages and using statements. Overall, it wasn’t too painful, even if I’d rather avoid doing it again.

Thanks for reading!