MVC动作方法 - 多视图 [英] MVC Action Method - Multiple Views

查看:51
本文介绍了MVC动作方法 - 多视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有两个不同的名字,即ContactUs,Enquirenow。对于ContactUs查看有布局,另一个是没有。我可以为两个视图使用单个Action方法,如果是,我应该如何在Action方法中调用...

hi to all,
i am having same view with two different names i.e ContactUs, Enquirenow. for ContactUs View having layout,other one is no. can i have single Action method for both views , if yes how should i call in Action method...

推荐答案

是的,这是可能的。简单地说,





yes it is possible. simply,


public ActionResult(bool isRenderingContactUS = false)
{
//all your code here

//and just before returning
if(isRenderingContactUS)
{
return View("ContactUS"); 
}
else
{
return View("Enquirenow");
}
}


这篇关于MVC动作方法 - 多视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆