0
我有以下看法如何在獲取請求時在地址欄上顯示任何值?
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using(Html.BeginForm("Create", "Concepts", new { name="sfsfsfsfsf", gio="sfsf9s9f0sffsdffs", ford="mtp"}, FormMethod.Get, null))
{
<input type="submit" name="name" value="New" />
}
當我點擊新建按鈕如何顯示的值gio
,ford
和name
的網址是什麼?
這是我的路線定義
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
您添加路由值,而不是查詢字符串值。您需要定義特定的路線,或添加隱藏的輸入。顯示你的路由定義和'Create'方法的簽名(你也需要從按鈕中刪除'name =「name」') –
@StephenMuecke你讓我在那裏:)什麼是路由定義及其用途 – zeelong
添加代碼根據我的第一條評論,我將添加一個答案,解釋你必須做什麼(你現有的路由定義在'RouteConfig.cs'文件中定義) –