What replaced HttpOperationHandler in WCF Web API to ASP.NET Web API - asp.net-web-api

In upgrading an old project that was built using WCF Web API to now use ASP.NET Web API, I have run into a few classes that implement HttpOperationHandler<HttpRequestMessage, T>. I'm unable to find an equivalent class in the new assemblies. Does something similar exist or will I need a different approach?

The concept of Operation handlers has been replaced with Filters and model binders.
Here are some links that you might find useful:
How to Migrate from WCF Web API to ASP.NET Web API
Mike's blog on How WebAPI does Parameter Binding
Getting started tutorials on ASP.NET WebAPI page.
Hope this helps.

Related

ASP.NET Boilerplate with Blazor - just use the service layer?

Even though ASP.NET Boilerplate does not seem to support Blazor, is there any reason you could not use it instead of the MVC/Angular frontend and just consume the REST services provided in the ASP.NET Boilerplate Service Layer? Or are there better alternatives for that setup?
Thanks.

How to share DbContext between different WebApps?

I've one missing link to understood how it could work to "connect" my EF core's DbContext to different applications in following scenario:
I've got one application project which contains the whole EF Core Code first datamodel (Entities, Business Logic, Enums etc).
Until now we're using a WebAPI application to share data with multiple endpoints.
So the data we're exchanging now are quite static at the moment. We create our DbContext and the API is using it for data reading and write operations.
Now there is customer request to also build a WebUI (Blazor). So we still want to use the WebAPI for data exchange in the UI, but further we need some more business logic elements from our data model (containing INotifyPropertyChanged event handling etc). We implemented the event handles in the entity classes. So we intend to build a session object for each user/client which contains the DbContext instance. But how can handover an instantiated DbContext from the Web API to my UI Application.
Would be nice to get some input. Thx for any advice.
You do not pass the DBContext object to "UI Application", such as a Blazor app.
You did not mention what flavor of Blazor you are using... However, the following may be applicable for both Blazor Server App and Blazor WebAssembly App... From what I've gather from your question you are exposing Web Api end points to retrieve data and save data. This is good. What is left for you to do is to create code in your Blazor that access those end points. You should use the HttpClient service to do this. If you use Blazor client side, this object is configured and made available for injection in your components and services. This type of HttpClient is based on the JavaScript Fetch Api.
If you are going to create a Balzor Server App, then you'll have to add the HttpClient service to the DI container and configure it accordingly, and only then you'd be able to inject it into your components and services. In this case you should use the IHttpClientFactory to provide the HttpClien onjects.
In principle, you have to query your Web Api methods via HttpClient.
Note that if you use Blazor Server App, you don't have to use Web Api. Instead you can create services that perform similar functionality to that provided by the Web Api.
Please, go to the docs and acquaint yourself how to use the HttpClient with Blazor apps.
Hope this helps...

How to implement soa concept in asp.net web api project?

I know some basic concepts about SOA. But I don't know how I can develop a project based on SOA. So, I want to know a way for implementing SOA in Asp.NET Web API project.
SOA is not a technology but a style of design/Architecture. There are different implementations of this. They are as follows.
Web services based on WSDL and SOAP
Messaging, e.g., with ActiveMQ, JMS, RabbitMQ
RESTful HTTP, with Representational state transfer (REST) constituting its own constraints-based architectural style
OPC-UA
WCF (Microsoft's implementation of Web services, forming a part of WCF)
Apache Thrift
SORCER
ASP.Net Core supports REST api and if you looking at implementing SOAP based service using asp.net core here is a handy link for this
https://stackify.com/soap-net-core/
There are many videos on youtube and there are many websites to learn REST services. If you are familiar with c# and asp.net, you can start learn ASP.NET Core to build your restful services.
Here is a link to one video links.

WCF Data Service vs WebAPI

I have been catching up with MVC4 Web API and WCF Data Service. From the surface, they both seem to be able to work with oData in the consuming client. I wonder which one is better for separation of concern (separate data service layer from UI layers). In my current solution, I have a plain MVC 3 style Intranet project and a MVC Data Service project. The 1st project has a Service Reference to the 2nd project. My goal is to write the data service once and make it available to all projects that would need to access underline database. When I read about Web API, it seems to me that the ApiControllers can return oData compliant result to the consuming client without MVC Data Service. My confusion is how I am going to expose this Web API MVC project as a service endpoint. Should I wrap it in WCF? Thanks.
You just create a controller inheriting ApiController and decorate one action with [Queryable] attribute, Rest depends on your route setup. Easy-Peasy.
Which one better? Web API. Since it has all the goodness of HTTP and you are not restricted to ATOM format.
You may use PocoHttp for seamless access of the data from your client.

Share WCF RIA Services between ASP.NET MVC and Silverlight clients

I want to use WCF RIA Services as the middle tier for multiple clients including Silverlight and ASP.NET MVC.
I created a solution with Domain classes in a separate assembly using WCF RIA Services 4.2 CTP and Database First, which I want to share between the Silverlight and MVC clients. The solution looks like this:
Solution Foo
Foo.RIAServices.Server.Entities
Foo.RIAServices.Server.Entities
Foo.RIAServices.Server.Entities.Web
Foo.RIAServices.Client
Foo.RIAServices.Client.Web
FooMvcApplication
FooMvcApplication.Tests
FooResources
What if anything is wrong with my architecture and approach? Is there a better approach to using the Microsoft Entity Framework to create a common service for multiple clients?
Can I create a common custom Authentication service for both? Will the [EnableClientAccess()] and [RequiresAuthorization] decorations be respected for all clients?

Resources