运行不同的框架并排侧OWIN框架、不同、OWIN

2023-09-04 00:32:49 作者:军权

我的IM $ P $的Owin很大的好处之一pssion是,它可以很容易地运行不同的Web框架并排侧没有IIS的的IHttpHandler 。 (这将是巨大的用于分配功能垂直切片作为的NuGet特征。)

My impression of one of the big benefits of Owin is that it makes it easy to run different web frameworks side-by-side without IIS's IHttpHandler. (This would be huge for distributing vertical functionality slices as nuget features.)

不过每个教程和文章中,我发现像自我主机和一个单一的框架谈判。这不是我感兴趣的,我感兴趣的运行MVC,南希,网络API,甚至在同一个应用web表单。

However every tutorial and article I find talks of things like self-host and a single framework. This is not what I'm interested in, I'm interested in running mvc, nancy, web api, maybe even webforms in the same application.

难道我错了OWIN启用此?说我想

Am I wrong about OWIN enabling this? Say I want

的mvc处理大多数请求 在Web表单处理其中有一个版本的请求=传统报头 南希来处理请求/南希/...

如何配置我的启动类来实现这一点?

How would I configure my Startup class to enable this?

推荐答案

虽然使用情况听起来有点荒唐,你是绝对正确的OWIN实现这一点。你可以撰写你的各种疯狂的方式流水线。

Although the use case sounds a bit absurd, you're absolutely right that OWIN enables this. You can compose your pipeline in all kinds of crazy ways.

一个典型的直管道将是这个样子:

A typical "straight" pipeline would look something like this:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseWebApi(new MyHttpConfiguration());
        app.MapSignalR();
        app.UseNancy();
    }
}

这将如下工作(给你主持的的http://本地主机/

This will work as follows (given you're hosting on http://localhost/)

的WebAPI - 的http://本地主机/ API / * (默认路由) SignalR - 的http://本地主机/ signalr (默认路由) 南希 - 的http://本地主机/ * (将处理一切) WebAPI - http://localhost/api/* (default routing) SignalR - http://localhost/signalr (default route) Nancy - http://localhost/* (will handle everything else)

您还可以创建在您的管道分支:

You can also create branches in your pipeline:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseWebApi(new MyHttpConfiguration());

        app.Map("/newSite", site =>
        {
            site.MapSignalR();
            site.UseNancy();
        });
    }
}

这将如下工作(给你主持的的http://本地主机/

This will work as follows (given you're hosting on http://localhost/)

的WebAPI - 的http://本地主机/ API / * (默认路由) SignalR - 的http://本地主机/ newSite / signalr (默认路由) 南希 - 的http://本地主机/ newSite / * (将处理一切) WebAPI - http://localhost/api/* (default routing) SignalR - http://localhost/newSite/signalr (default route) Nancy - http://localhost/newSite/* (will handle everything else)
 
精彩推荐
图片推荐