diff --git a/Unosquare.Labs.EmbedIO/Middleware.cs b/Unosquare.Labs.EmbedIO/Middleware.cs
index 388531f6b..feebe4542 100644
--- a/Unosquare.Labs.EmbedIO/Middleware.cs
+++ b/Unosquare.Labs.EmbedIO/Middleware.cs
@@ -1,6 +1,7 @@
namespace Unosquare.Labs.EmbedIO
{
using System.Net;
+ using System.Threading.Tasks;
///
/// Represents a Middleware abstract class
@@ -11,7 +12,7 @@ public abstract class Middleware
/// Invokes the Middleware with a context
///
/// The Middleware context
- public abstract void Invoke(MiddlewareContext context);
+ public abstract Task Invoke(MiddlewareContext context);
}
///
@@ -46,4 +47,4 @@ public MiddlewareContext(HttpListenerContext httpListenerContext, WebServer webs
WebServer = webserver;
}
}
-}
+}
\ No newline at end of file
diff --git a/Unosquare.Labs.EmbedIO/WebServer.cs b/Unosquare.Labs.EmbedIO/WebServer.cs
index f396ddd06..a60dd7324 100644
--- a/Unosquare.Labs.EmbedIO/WebServer.cs
+++ b/Unosquare.Labs.EmbedIO/WebServer.cs
@@ -1,4 +1,6 @@
-namespace Unosquare.Labs.EmbedIO
+using System.Globalization;
+
+namespace Unosquare.Labs.EmbedIO
{
using System;
using System.Collections.Generic;
@@ -240,7 +242,7 @@ public void UnregisterModule(Type moduleType)
///
/// The context.
///
- private void HandleClientRequest(HttpListenerContext context, Middleware app)
+ private async void HandleClientRequest(HttpListenerContext context, Middleware app)
{
// start with an empty request ID
var requestId = "(not set)";
@@ -251,7 +253,7 @@ private void HandleClientRequest(HttpListenerContext context, Middleware app)
if (app != null)
{
var middlewareContext = new MiddlewareContext(context, this);
- app.Invoke(middlewareContext);
+ await app.Invoke(middlewareContext);
if (middlewareContext.Handled) return;
}
@@ -259,7 +261,7 @@ private void HandleClientRequest(HttpListenerContext context, Middleware app)
// Create a request endpoint string
var requestEndpoint = string.Join(":",
context.Request.RemoteEndPoint.Address.ToString(),
- context.Request.RemoteEndPoint.Port.ToString());
+ context.Request.RemoteEndPoint.Port.ToString(CultureInfo.InvariantCulture));
// Generate a random request ID. It's currently not important butit could be useful in the future.
requestId = string.Concat(DateTime.Now.Ticks.ToString(), requestEndpoint).GetHashCode().ToString("x2");