我在ASP.NET MVC Core RC2
中使用VS2015
。我在Controllers文件夹中有一个名为TestController
的控制器,如下所示:
// GET: /<controller>/
public IActionResult Index()
{
ViewBag.Mesage = "Test message";
return View();
}
名为TestRel.chtml
的相应视图位于文件夹Views/Northwind
内,如下所示:
@{
<label>Test view</label>
}
但是,为了测试,当我运行绝对网址http://localhost:49944/Test/Index
时,我收到以下错误:
InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Test/Index.cshtml
/Views/Shared/Index.cshtml
Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable`1 originalLocations).
如何使用绝对网址显示上述视图?
答案 0 :(得分:0)
如果我使用return view("~/views/northwind/TestRel.cshtml");
或将其放入views / test /,return view("testrel");