0

我的观点如下:

@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,所以一些建议会很好吗?

4

2 回答 2

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 的值]

希望这可以帮助。

于 2013-07-20T18:26:21.777 回答
0

您需要更改 global.ascx.cx 文件中的 url 重写

于 2013-07-20T18:16:31.237 回答