(╯°□°)╯︵ ┻━┻
Mar 18, 2016
  2576
(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.

EpiserverWebApiErrorHandler


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.

EpiserverWebApiOutputCacheAttribute

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.

WebApiLanguageAttribute


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.

ValidateWebApiModelAttribute


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

Comments

Please login to comment.
Latest blogs
Change texts in TinyMCE, inside Optimizely CMS 12

Not happy with some of the default texts in TinyMCE? Don't worry, simply update them.

Tomas Hensrud Gulla | Oct 16, 2024 | Syndicated blog

Headless with Content Delivery API

Hello Everyone, This blog will help anyone who wants to start or build an architecture of headless using content delivery api. When we shifted to...

PuneetGarg | Oct 15, 2024

Introducing Optimizely Graph Source .NET SDK

Overview Of Optimizely Graph Optimizely Graph is a cutting-edge, headless content management solution designed to integrate seamlessly with any...

Jake Minard | Oct 15, 2024

SEO redirects in .NET + Optimizely

Nice and easy way to add necessary SEO redirects

Damian Smutek | Oct 14, 2024 | Syndicated blog