【发布时间】:2011-02-15 04:56:25
【问题描述】:
我正在开发一个采用 ASP.NET MVC3(Razor) 技术的项目。 现在,我在下面有一个控制器:
public class Home: Controller
{
public ActionResult Result(string id)
{
return View(id);
}
}
我已将 MapRoute 设置如下:
context.MapRoute(
"Home_result",
"Home/Result/{id}",
new { controller="Home", action = "Result"}
);
当我在浏览器中输入 url http://domain.com/Home/Result/abc123 时,它应该显示一个名为“Result”的视图。然而它没有。 相反,它在下面给了我一个例外:
The view 'Result' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/abc123.cshtml
~/Views/Home/abc123.vbhtml
~/Views/Shared/abc123.cshtml
~/Views/Shared/abc123.vbhtml
很奇怪不是吗? 谁能帮我弄清楚我犯了什么错误?
【问题讨论】:
-
删除该路线。有什么意义?在这种情况下,默认路由就足够了。
标签: asp.net-mvc-3