Browse.chtml
사용자가 검색어를 입력하거나 검색어를 비워 둘 수 있는보기가 있습니다. 검색어를 입력 할 때 페이지를로 연결 http://localhost:62019/Gallery/Browse/{Searchterm}
하고, 아무것도 입력하지 않은 경우 브라우저를로 연결하고 싶습니다 http://localhost:62019/Gallery/Browse/Start/Here
.
이것을 시도하면 오류가 발생합니다.
컨트롤러 유형 'GalleryController'의 'Browse'작업에 대한 현재 요청은 다음 작업 메서드간에 모호합니다. System.Web.Mvc.ActionResult Browse (System.String) on type AutoApp_MVC.Controllers.GalleryController System.Web.Mvc.ActionResult Browse (Int32, System.String) AutoApp_MVC.Controllers.GalleryController 형식
내가 MVC로하는 모든 일은 처음입니다. 이 시점에서 무엇을 시도해야할지 잘 모르겠습니다.
public ActionResult Browse(string id)
{
var summaries = /* search using id as search term */
return View(summaries);
}
public ActionResult Browse(string name1, string name2)
{
var summaries = /* default list when nothing entered */
return View(summaries);
}
Global.asax.cs에도 다음이 있습니다.
routes.MapRoute(
"StartBrowse",
"Gallery/Browse/{s1}/{s2}",
new
{
controller = "Gallery",
action = "Browse",
s1 = UrlParameter.Optional,
s2 = UrlParameter.Optional
});
routes.MapRoute(
"ActualBrowse",
"Gallery/Browse/{searchterm}",
new
{
controller = "Gallery",
action = "Browse",
searchterm=UrlParameter.Optional
});