在ASP.NET MVC上使用绝对路径访问视图 [英] Accessing views with absolute paths on ASP.NET MVC
本文介绍了在ASP.NET MVC上使用绝对路径访问视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试以这种方式访问视图:
I'm trying to access a view in this way:
return View(@"~\Items\Details.aspx");
我得到这个错误:
找不到视图〜\ Items \ Details.aspx"或其主视图.搜索了以下位置: 〜\ Items \ Details.aspx
The view '~\Items\Details.aspx' or its master could not be found. The following locations were searched: ~\Items\Details.aspx
在ItemsController上的Details动作中,返回View()很好.为什么我不能从另一个控制器访问该视图?
On the ItemsController, in the Details action, returning View() works just fine. Why can't I access that view from another controller?
推荐答案
以'/Views'作为前缀应该会有所帮助.
Prefix it with '/Views' should help.
return View("~/Views/Items/Details.aspx");
这篇关于在ASP.NET MVC上使用绝对路径访问视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文