C# 查看引擎can';我找不到我的观点
尝试从post操作返回ViewResult时,我遇到以下错误: 找不到视图“索引”或其主视图,或者没有视图引擎支持搜索的位置。搜索了以下地点: ~/Views/Home/Index.cshtml ~/Views/Shared/Index.cshtml ~/Views/Home/Home.cshtmlC# 查看引擎can';我找不到我的观点,c#,asp.net,asp.net-mvc,asp.net-mvc-4,viewengine,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Viewengine,尝试从post操作返回ViewResult时,我遇到以下错误: 找不到视图“索引”或其主视图,或者没有视图引擎支持搜索的位置。搜索了以下地点: ~/Views/Home/Index.cshtml ~/Views/Shared/Index.cshtml ~/Views/Home/Home.cshtml ~/Views/Shared/Home.cshtml ~/Views/Home/Index.aspx ~/Views/Home/Index.ascx ~/Views/Shared/Index.asp
~/Views/Shared/Home.cshtml ~/Views/Home/Index.aspx
~/Views/Home/Index.ascx ~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx ~/Views/Home/Home.master
~/Views/Shared/Home.master ~/Views/Home/Home.vbhtml
~/Views/Shared/Home.vbhtml 我的观点得到了肯定的认可,因为它适用于GET操作 在POST操作中返回ViewResult的代码为:
return View("Index", "Home", Model);
有人能提出为什么这不起作用吗
更详细一点:
“获取”操作将显示视图。post操作实际上指向不同的url,但返回相同的视图。导致问题的是后期操作。GET和POST操作都在同一个控制器上HomeController
这是(精简的)控制器:
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index()
{
return View(new LoginModelBase());
}
[HttpPost]
public ActionResult Login(UsernameLoginModel Model)
{
...
return View("Index", "Home", Model);
}
}
我刚刚意识到这是什么!。我使用了
视图(…)
方法的错误重载
应该是:
View("Index", Model);
你能发布更多的代码吗?…两个URL都指向同一路径吗?你在项目中使用RazorGenerator吗?@KirillBestemyanov Razor generator被引用的项目使用。该40; u)布局来自上述项目。此视图未使用razor生成器。@AmiramKorach。获取url为或。POST url是肯定的,“主页”指的是主机,而不是控制器。