由于某种原因,视图引擎正在根据字符串值搜索视图,我将其作为视图模型传递。我使用ASP.NET MVC 4ASP.NET MVC View looking by Model value
这是我的操作方法的简化版本。这显示在没有发现标签错误情况,而是或返回默认查看我返回不同的错误页面视图“TagNotFound”:
public ActionResult Tagged()
{
string tag = "SomeValue";
return View("TagNotFound", tag);
}
TagNotFound.cshtml
存在,但搜索是错误的观点。这是我的错误:
The view 'TagNotFound' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Tag/SomeValue.cshtml
~/Views/Tag/SomeValue.vbhtml
~/Views/Shared/SomeValue.cshtml
~/Views/Shared/SomeValue.vbhtml
而不是使用一个类来调用正确的过载的建议我投的字符串作为一个对象。
return View("TagNotFound", (object)tag);
你定制任何ASp.NET MVC框架组件?你是否也有任何自定义路线? –
没有自定义。大卫下面解释了为什么会这样。 – David