-2
我在舊視圖中創建了一個新的視圖創建按鈕。我無法從Action或url中打開新視圖。不在mvc 4中調用新創建的視圖甚至存在視圖
Controller: HomeController
OlderView: Index (View/Home/Index.cshtml)
Action: Success
NewView: Success (View/Home/Success.cshtml)
Index.cshtml:
<input type="button" value="Download" onclick="location.href='@Url.Action("Success", "Home")'" />
的HomeController:
[HttpPost]
public ActionResult Success()
{
//return View(); //this also doesn't work
return View("Success");
}
Success.cshtml:
@{
ViewBag.Title = "Success";
}
<h2>Your transaction has been completed successfully.</h2>
如果我直接從URL嘗試:http://xxx.xxx.x.xx:xxxx/Home/Success,扔以下錯誤
說明:HTTP 404.您正在查找的資源(或其某個依賴項)可能已被刪除,名稱已更改或暫時不可用。請檢查以下網址並確保它拼寫正確。
請求的URL:/首頁/成功
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.6.1069.1
有人能告訴我我在這裏失蹤了嗎?我需要在任何地方註冊視圖嗎?
刪除' [HttpPost]''成功''控制器行爲的屬性。 –
@KartikeyaKhosla完成了。謝謝。 –