0

次の記事に示すように、XML RPCサービスを実行しようとしています:http: //www.cookcomputing.com/blog/archives/Implementing%20an%20xml-rpc-service-with-asp-net-mvc

ルーティングを除いて、すべてがうまく機能します。これは、このSOの質問で説明したものと同様の問題です。MVCルートがサービスルートと競合します

RegisterRoutesの私のコードは次のようになります。

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

        routes.Add(new Route("wlw/publish", new WLWRouteHandler()));

    }

この行を入れると

routes.Add(new Route("wlw/publish", new WLWRouteHandler()));

MapRoutesの前はサービスにアクセスできますが、通常のルートは機能しません。4番目のパラメーターを追加してみました:

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            constraints: new { controller = "regex-for-!=-wlw" }

        );

しかし、403が表示されます。Webサーバーは、このディレクトリエラーの内容を一覧表示しないように構成されています。

私は何が間違っているのですか?

4

1 に答える 1

0

これに対する良い解決策はここで見つけることができます:http ://weblogs.asp.net/jasonconway/archive/2009/10/23/include-and-exclude-constraints-in-asp-net-mvc.aspx

MapRouteを次のように変更しました。

routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new { controller = "home", action = "index", id = "" },
            new { controller = new ListConstraint(ListConstraintType.Exclude, "wlw") }
        );
于 2013-03-27T11:57:05.113 に答える