I have a View called Browse.chtml
, where the user can enter a search term, or leave the search term blank. When entering the search term, I want to direct the page to http://localhost:62019/Gallery/Browse/{Searchterm}
and when nothing is entered, I want to direct the browser to http://localhost:62019/Gallery/Browse/Start/Here
.
When I try this, I get the error:
The current request for action 'Browse' on controller type 'GalleryController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Browse(System.String) on type AutoApp_MVC.Controllers.GalleryController System.Web.Mvc.ActionResult Browse(Int32, System.String) on type AutoApp_MVC.Controllers.GalleryController
Everything I'm doing with MVC is for the first time. I'm not sure what else to try at this point.
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);
}
I also have this in 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
});