【发布时间】:2018-02-14 22:01:34
【问题描述】:
从未找到“Test.cshtml”视图。
错误:未找到“测试”视图或其主视图,或者没有视图引擎支持搜索到的位置。
搜索了以下位置:
列出的地点有:
~/Views/SecondGroup/Test.aspx~/Views/SecondGroup/Test.ascx~/Views/SecondGroup/123.cshtml
但位置不正确,应该是"~/Views/SecondGroup/Test/123" ??
ViewOne.cshtml(由 FirstController 生成)
<button onclick= "@("window.location.href ='" + @Url.Action("Test",
"SecondController", new { id = "123" }) + "'");">
GO TO ANOTHER VIEW
</button>
第二控制器
public ActionResult Test(string id)
{
return View("Test", id); // here id = '123'
}
Test.cshtml
@model String
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div> .... </div>
这是文件夹结构:
---Controllers
--- HomeController
--- FirstController
--- SecondController
-- Views
--- FirstGroup
--- ViewOne
--- SecondGroup
--- Test
为什么永远找不到"Test.cshtml" 视图?
谢谢
【问题讨论】:
标签: asp.net-mvc razor asp.net-mvc-routing