次の URL を使用して単純な検索エンジンを構築しています。
"/" - this is the homepage with the search textbox and submission button.
"/search?q=" - this is where the results will appear. The query is the q= parameter.
これは私の検索コントローラーです:
[HandleError]
public class SearchController : Controller {
public ActionResult Start() {
SearchModel model = new SearchModel();
return View( model );
}
/// <summary>Performs a search.</summary>
/// <param name="q">The search query.</param>
/// <param name="a">The search action ("I Feel Lucky", etc).</param>
/// <param name="page">The results page number.</param>
public ActionResult Search(String q, String a, String page) {
return View();
}
}
最後に、これは私のルーティング テーブルです。
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"SearchQuery",
"Search", // match "http://mysite.com/Search"
new { controller = "Search", action = "Search" }
);
routes.MapRoute(
"SearchStart", // Route name
"", // match "http://mysite.com/"
new { controller = "Search", action = "Start", id = UrlParameter.Optional } // Parameter defaults
);
}
ただし、HTTP 要求を行うと、404 が返される場所http://mysite.com/Search?q=foo
への 301 リダイレクトが返されます。http://mysite.com/Search/
私のSearchController
。Search
アクションが呼び出されることはありません。
私がしていることを許可するには、何をする必要がありますか?