Skip to content
Riccardo De Agostini edited this page Aug 20, 2019 · 10 revisions

Upgrade guide for v2 users

General

  • The assembly name is now EmbedIO.dll (instead of Unosquare.Labs.EmbedIO.dll).
  • The root namespace is now EmbedIO (instead of Unosquare.Labs.EmbedIO).
  • Namespaces have been reorganized: instead of a code-type-based approach (Constants, Modules, etc.) now they follow a more common feature-based approach. For example you will find class WebApiModule, together with its support types, in namespace EmbedIO.WebApi (previously it was in Unosquare.Labs.EmbedIO.Modules).

Web server initialization

Gone are RegisterModule and Module<T>(): the preferred method of initialization is via fluent extension methods. Although there are plenty of them, they have consistent syntax and semantics, so they can be grasped in a few minutes. While we prepare more extensive documentation, you can find them here.

Routing

Wildcard routing strategy has been removed: routing is Regex-based everywhere.

HTTP context handlers

HTTP context handlers do not return bool any longer; instead, they are void functions (Subs, if you speak VB). Whether a HTTP context gets passed along to further modules is decided, by default, on a module-per-module basis, via the IWebModule.IsFinalHandler property; this default may be overridden by a handler, either by calling context.SetHandled() to stop futher processing, or with throw RequestHandler.PassThrough(); to skip the currently executing handler and pass the context along to subsequent modules.

Web API

Web API controller methods can now be void (or return Task) too.

A response with a status code different from 200 OK may be generated by throwing a HTTP exception (e.g. throw HttpException.Unauthorized();, throw HttpException.Redirect("/");, etc. - find them all here).

If a controller method returns a value or a Task<TResult>, the result is serialized and sent as response body.

BEWARE: Existing controller methods returning bool will generate JSON responses containing their serialized return value, as JSON is the default response serializer for web API modules.

Serving files

No more StaticFilesModule and ResourceFilesModule: the new FileModule (in namespace EmbedIO.Files, of course) uses an IFileProvider interface to abstract the file system and provides the same level of functionality (compression, caching, support for range requests) regardless of the underlying storage. File providers are available for static files, embedded resources, and (new!) ZIP files.

Fallback and "quick" actions

FallbackModule functionality has been split between ActionModule and RedirectModule. As you've probably guessed, their namespace is EmbedIO.Actions.

Unit testing support

Support types for unit testing have been moved to their own assembly EmbedIO.Testing.dll.