ASP.NET MVC视图“名称”或它的主人未找到 [英] ASP.NET MVC The view 'name' or its master was not found
本文介绍了ASP.NET MVC视图“名称”或它的主人未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个观点的问题。这里的code片断:
I have a problem with a View. Here's the code snippet:
public ActionResult AddAdvertisement()
{
...
return RedirectToAction("AdvCreated");
}
[HttpGet]
public ActionResult AdvCreated()
{
return View("AdvCreated", "abc");
}
然后我看到错误
视图AdvCreated或它的主人没有被发现。在以下地点进行了全面搜查:
〜/查看/广告/ abc.master
〜/查看/共享/ abc.master
如果我只是去到URL 的http://本地主机/ AdvCreated 一切正常。为什么呢?
If I just go to URL http://localhost/AdvCreated everything is OK. Why ?
推荐答案
我的理解是你想传递一个字符串以查看模式。这是不可能的。有这样取景功能的过载:
What I understand is you are trying to pass a string to View as model. It's not possible. There is an overload of View function like this:
View(string viewName,string masterViewName)
所以看起来名为abc的母版视图。如果你想传递一个字符串,将其转换为object.There就是一个例子<一个href=\"http://stackoverflow.com/questions/3178887/i-cant-pass-a-value-to-view/3179073#3179073\">here.
这篇关于ASP.NET MVC视图“名称”或它的主人未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文