I want to pass the value in my textbox 'location' to my route so that my route looks something like this
https://localhost:44300/Home/Results/San+Francisco?Day=01%2F28%F2015
right now my url looks like this
https://localhost:44300/Home/Results/5?Day=6
what do I change in the form to pass in San Francisco to the url as a parameter?
@{
var routeValues = new RouteValueDictionary {{"Location", "5"}, {"Day", "6"}};
}
@using (Html.BeginForm("Results", "Home", routeValues, FormMethod.Post))
{
<p>
<input type="text" name="location" id="location" placeholder="Search For Classes" />
</p>
<p>
<input class="btn btn-primary btn-lg" value='Submit' type="submit" />
</p>
}
Here is my route
routes.MapRoute(
name: "Results", // route name
url: "Home/Results/{location}", // URL with parameters
defaults: new { controller = "Home", action = "Results", location = UrlParameter.Optional }
);