如何为partialview指定路径? [英] How to specify path for a partialview?
本文介绍了如何为partialview指定路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图访问其他控制器中的视图,考虑我在支付控制器,但我试图使用欢迎控制器的局部视图,。 ..
Hi,
Im trying to access a view in other controller, consider im in payment controller, but im trying to use a partial view of welcome controller,...
public class welcomecontroler
{
public action steps(model)
{
return view(model)
}
}
public class payment{
public action sample()
{Model model = new Model();
return partialview("~/Views/welcome/steps",model);
//i tried all these ways
//return partialview("../Views/welcome/steps",model);
//return partialview("~/Views/welcome/steps.cshtml",model);
//return partialview("~/Views/welcome/steps",model);
//return partialview("../Views/welcome/steps.cshtml",model);
}
}
我试过的方式,它没有达到欢迎步骤的行动,......请帮帮我,..
提前致谢,
Anand
what ever way i tried, its not hitting the welcome steps action,.... please do help me,..
Thanks in advance,
Anand
推荐答案
MVC的逻辑不符合您的要求。
部分视图在控制器之间共享,而不是必须将其放在Shared文件夹中;或者它在单个控制器的视图之间共享,而不是将它放在控制器的视图下。请记住,MVC正在使用惯例 [ ^ ]。请查看以下文章: http://coding-in.net/mvc-3-组织你的部分观点/ [ ^ ]。
但是你可以影响搜索路径。请参阅以下文章: http://www.leonamarant.com/2011/02/17/adding-a-custom-directory-to-razor-view-engine-partial-view-locations-in-asp-net -mvc3 / [ ^ ]
The logic a MVC is not conforming to what you desire.
A partial view is either shared between controllers, than you have to place it in the Shared folder; or it is shared between views of a single controller, than you can place it under controller''s views. Please remember, that MVC is using conventions[^]. Please look at the following article: http://coding-in.net/mvc-3-organize-your-partial-views/[^].
But you can however influence the search paths. See following article: http://www.leonamarant.com/2011/02/17/adding-a-custom-directory-to-razor-view-engine-partial-view-locations-in-asp-net-mvc3/[^]
这篇关于如何为partialview指定路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文