Visual studio 2015 无法使用绝对url在子文件夹内显示视图
我正在Visual studio 2015 无法使用绝对url在子文件夹内显示视图,visual-studio-2015,asp.net-core,Visual Studio 2015,Asp.net Core,我正在VS2015中使用ASP.NET MVC核心RC2。我在控制器文件夹中有一个名为TestController的控制器,如下所示: // GET: /<controller>/ public IActionResult Index() { ViewBag.Mesage = "Test message"; return View(); } @{ <label>Tes
VS2015
中使用ASP.NET MVC核心RC2
。我在控制器文件夹中有一个名为TestController
的控制器,如下所示:
// GET: /<controller>/
public IActionResult Index()
{
ViewBag.Mesage = "Test message";
return View();
}
@{
<label>Test view</label>
}
但是,为了测试,当我运行绝对URLhttp://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).
如何使用绝对URL显示上述视图?如果使用
返回视图(“~/views/northwind/TestRel.cshtml”)代码>或将其放置在视图/test/,返回视图(“testrel”)代码>如果我使用返回视图(“~/views/northwind/TestRel.cshtml”)代码>或将其放置在视图/test/,返回视图(“testrel”)代码>现在,我得到以下错误:处理请求时发生未处理的异常。InvalidOperationException:未找到视图“/views/Northwind/TestRel.chtml”。搜索了以下位置:/views/Northwind/TestRel.chtml Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable
1 originalLocations)`您可以通过添加额外的“~”来尝试吗。。“返回视图(“~/views/northwind/TestRel.chtml”);”我得到了与上面类似的错误:InvalidOperationException:找不到视图'~/views/northwind/TestRel.chtml'。搜索了以下位置:~/views/Northwind/TestRel.chtml Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable
1 originalLocations)`chtml=>cshtml。很抱歉输入了返回视图(“/views/northwind/TestRel.cshtml”)代码>一个有效。感谢您的帮助。现在,我得到以下错误:处理请求时发生未处理的异常。InvalidOperationException:未找到视图“/views/Northwind/TestRel.chtml”。搜索了以下位置:/views/Northwind/TestRel.chtml Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable
1 originalLocations)`您可以通过添加额外的“~”来尝试吗。。“返回视图(“~/views/northwind/TestRel.chtml”);”我得到了与上面类似的错误:InvalidOperationException:找不到视图'~/views/northwind/TestRel.chtml'。搜索了以下位置:~/views/Northwind/TestRel.chtml Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable
1 originalLocations)`chtml=>cshtml。很抱歉输入了返回视图(“/views/northwind/TestRel.cshtml”)代码>一个有效。谢谢你帮助我。