简体   繁体   中英

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
partail view which comes by default named _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
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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM