How do you customize a url for a form with Asp MVC?
Posted
by
Maudite
on Stack Overflow
See other posts from Stack Overflow
or by Maudite
Published on 2011-01-14T20:31:29Z
Indexed on
2011/01/14
23:54 UTC
Read the original article
Hit count: 170
asp.net-mvc-3
I am adding a search box to a Asp Mvc.
This is html for the form:
@using (Html.BeginForm("Query", "Search", FormMethod.Get))
{
<input type="text" name="q" />
<input type="submit" value="Seach" />
}
and I added this route
routes.MapRoute("Search", "q={query}",
new { controller = "Search", action = "Query" });
I would like the form to generate a url that looks like http://localhost:####/q=value in textbox
.
Is it possible to change the way MVC generates the url? This is currently what I get:
http://localhost:50916/Search/Query?q=value in textbox
© Stack Overflow or respective owner