0

次の2つのルートが定義されているとします。

routes.MapRoute(name: "StateResultsCategory", url: "{state}/{category}/{searchTerm}", defaults: new { controller = "Results", action = "SearchStateCategory" });

routes.MapRoute(name: "FRStateResults", url: "fr/{state}/{searchTerm}", defaults: new { controller = "Results", action = "SearchStateFR" });

最初のルートは、「fr」をトラップし、それを「fr」の間違ったアクションに渡すことです。

後で他の言語固有のルートがある可能性があるため、最初のルートに制約を設定したくありません。すなわち。

routes.MapRoute(name: "CHStateResults", url: "ch/{state}/{searchTerm}", defaults: new { controller = "Results", action = "SearchStateCH" });
routes.MapRoute(name: "SPStateResults", url: "sp/{state}/{searchTerm}", defaults: new { controller = "Results", action = "SearchStateSP" });

これに対応するためのルートを設定するにはどうすればよいですか?

ありがとう。

4

1 に答える 1

0

The order in which you place your routes makes a difference.

Placing your more specific routes above the more generic routes ensures they won't get caught up in the more generic version.

于 2011-06-09T16:34:52.997 に答える