我有以下观点:
@using (Html.BeginForm("Index", "ToolsForHire", FormMethod.Get))
{
<p>tool required: @Html.TextBox("tool")</p>
<input type="submit" value="search" />
}
将此表单提交至:
localhost:54124/ToolsForHire?tool=mytooltext
一切正常。
然而,我想要发生的是我的网址最终成为:
localhost:54124/ToolsForHire/mytooltext
仍然掌握着mvc所以一些建议会很好吗?
答案 0 :(得分:1)
您可能希望使用以下BeginForm扩展方法BeginForm(action, controller, routevalues, FormMethod)
路线值是
的路线new {tool = mytooltext}
通常,默认路由设置为期望id可选参数,因此路由值为
@using (Html.BeginForm("Index", "ToolsForHire", new {id = mytooltext}, FormMethod.Get))
然后url的结果将是http:// localhost / ToolsForHire / [mytooltext的值]
希望这有帮助。
答案 1 :(得分:0)
您需要更改global.ascx.cx文件中的网址重写