简体   繁体   English

显示部分视图取决于调用的Action和Controller

[英]Show partial view depends on the calling Action and Controller

As every one know that by default there is a layout page 每个人都知道默认情况下有一个布局页面
when you create project in mvc3 , and also there is a 当您在mvc3中创建项目时,还有一个
partail view which comes by default named _LogOnPartial.cshtml 默认情况下名为_LogOnPartial.cshtml
where login and logout links are availble and it renders on layout page . 登录和注销链接可用并在布局页面上呈现的位置。
I want that when i call home page which is inherited from layout , then 我希望当我调用从layout继承的主页时,
those login and logout links not show on home page 这些登录和注销链接未显示在主页上
...... ......
In short i don't want to render _LogOnPartial.cshtml when i call home page . 简而言之,我不想在调用主页时呈现_LogOnPartial.cshtml

@if (ViewContext.RouteData.Values["Controller"] != "Foo" &&  
     ViewContext.RouteData.Values["Action"] != "Bar")
{
    // call the partial you want here.
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过调用控制器的动作将部分视图转换为字符串 - Transform partial view into string with calling controller's action 在选项卡视图中创建选项卡,调用控制器操作以返回部分视图 - create tabs inside a tab view calling a controller action that returns a partial view 将viewbag从动作控制器传递到局部视图 - Pass viewbag to partial view from action controller 将数据从局部视图传递到控制器操作 - Pass data from partial view to controller action 调用另一个控制器的动作并以字符串形式获取视图 - Calling an action of another controller and getting view as a string 是否应在父视图的控制器中编写局部视图的操作方法? - Should I write action methods of the partial view in the controller of the parent view? 从局部视图重定向时在MVC中调用Action - Calling an Action in MVC when redirected from a partial view 在渲染局部视图时如何调用控制器操作? - How can I call a controller action when rendering a partial view? 在Ajax成功函数上的控制器中调用操作方法以渲染部分视图 - Call Action Method in controller on Ajax success function to Render partial view 从局部视图中获取当前控制器和操作 - Getting current controller & action from within partial view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM