(╯°□°)╯︵ ┻━┻
Mar 18, 2016
(6 votes)

NuGet: Solita.Episerver.WebApi - WebApi toolkit for Episerver

We, Solita, wish to share our WebApi productivity improvements as a NuGet package, and of course in open source. The source code was released for public in February, but we have used the most of it in production for over a year* with great results. Feel free to implement, contribute and fork :)

NuGet: https://nuget.episerver.com/en/OtherPages/Package/?packageId=Solita.Episerver.WebApi
GitHub: https://github.com/solita/episerver-webapi

What can it do for you?

1. WebApi error logging
By default, Episerver does not log exceptions that happen during WebApi requests. This ExceptionHandler will log the exact URL and the stacktrace. And if you are on the localhost, or an Admin, WebAdmin or WebEditor user, you also get the stacktrace as a result when executing the request to ease debugging, otherwise a plain "An error has occurred" is returned to the caller for security reasons. Here is a log example.


2. WebApi output caching
Attribute that caches the result for a requested WebApi method. The cache is invalidated when Episerver content changes, so no need to worry about it getting stale. This helps a lot on pages that execute the same XHR request on every load.


3. WebApi language context
Attribute that automatically sets the correct language context when the WebApi method is called with a language parameter. After that, you can access the Episerver APIs without explicitly defining the language, just like with PageControllers.


4. WebApi automatic model validation
Attribute that automatically returns HTTP Bad Request (400) with error details if the model validations fail. No need to do the checks manually in the controller.


5. WebApi StructureMap DependencyResolver
StructureMap DependencyResolver for WebApi to avoid boilerplate code in the project.

Please see the the GitHub page for the latest and more detailed information. We also aim to keep the code as easy to read as possible since it is the documentation :)

* With minor changes the code works with Episerver 8. The latest we have in production is using EPiServer.CMS.Core 9.7.2.

Mar 18, 2016


Please login to comment.
Latest blogs
Optimizely Web Experimentation Metrics

Within the domain of Optimizely Web Experimentation Metrics, the emphasis is on objective key performance indicators (KPIs) selected to assess an...

Matthew Dunn | Sep 23, 2023 | Syndicated blog

Optimizely For you Intranet

Having been at Optimizely and in the CMS industry for nearly 16 years I have seen clients’ intranet requirements go from a simple site just to hous...

Robert Folan | Sep 22, 2023

Vulnerability in EPiServer.GoogleAnalytics v3 and v4

Introduction A potential security vulnerability was detected for Optimizely Google Analytics addon (including EPiServer.GoogleAnalytics and...

Bien Nguyen | Sep 20, 2023

Overriding Optimizely’s Content Recommendations Block to Implement Custom Recommendations

Introduction The Content Recommendations add-on for Optimizely CMS dynamically recommends content from your site tailored to the interests of each...

abritt | Sep 13, 2023 | Syndicated blog