Using self-hosted OWIN I have implemented the following in order to handle JS XHR requests coming from HTML pages. Is there a better way to do this with OWIN?

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseFileServer(new FileServerOptions
        {
            FileSystem = new PhysicalFileSystem(string.Format("{0}{1}Web{1}Dashboard", Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), Path.DirectorySeparatorChar))
        });
        app.Use&lt;Middleware&gt;();
    }
}

public class Middleware : OwinMiddleware
{
    private readonly List&lt;string&gt; _knownRequests = new List&lt;string&gt;
    {
        "Request"
    };

    public Middleware(OwinMiddleware next)
        : base(next)
    {
    }

    public override async Task Invoke(IOwinContext context)
    {
        #region Invoke Next Context

        await Next.Invoke(context);

        #endregion

        #region Handle Request

        var request = context.Request;
        var response = context.Response;
        var path = request.Path.Value.TrimStart('/');
        if (!_knownRequests.Contains(path))
            return;

        response.StatusCode = 200;

        switch (path)
        {
            case "Request":
            {
                await response.WriteAsync("RESPONSE!");
                break;
            }
        }

        #endregion
    }
}
Only focusing on the code in question (not on OWIN)

Using region outside of methods is discussed controversially but using region's inside a method is clearly a code smell. It indicates that a method is too big or worse that a method has too many responsibilities.  



Instead of adding "Request" to the List and using the string "Request"  in the switch you should declare a const holding "Request" and which you should add to the List and use it in the switch to reduce the possibility of spelling errors.  



Using a switch for a single case should be better changed to a simple if statement.  



You should use braces {} for single statements if's too. This will make your code less error prone.  



Variables should be declared as near as possible to their usage. So changing  


var request = context.Request;
var response = context.Response;
var path = request.Path.Value.TrimStart('/');
if (!_knownRequests.Contains(path))
    return;

response.StatusCode = 200;  



to 

var request = context.Request;
var path = request.Path.Value.TrimStart('/');
if (!_knownRequests.Contains(path))
{
    return;
}

var response = context.Response;
response.StatusCode = 200;  


would be better.  



Using the var keyword should be only done when the type of the right hand side of the declaration is obvious.
This is only true for the last usage here:  


var request = context.Request;
var response = context.Response;
var path = request.Path.Value.TrimStart('/');



so better change it to  

IOwinRequest request = context.Request;
IOwinResponse response = context.Response;
var path = request.Path.Value.TrimStart('/'); 


but using the request does not add to much value here,because it is only used once, so you could just change it to  

IOwinResponse response = context.Response;
var path = context.Request.Path.Value.TrimStart('/');