html5 - Message displays as "Element 'title' occurs too many times. How to use a single "Title" tag here? -


message displays "element 'title' occurs many times. how use single "title" tag here?

        <head>         ...         @if (viewbag.title != null)         {             <title>@viewbag.title</title>         }         else         {             <title>mytitle</title>         }         ...         </head> 

you try this, sets local variable called title , uses null coalescing operator either set viewbag.title or "mytitle" if that's null.

@{var title = viewbag.title ?? "mytitle";} <title>@title</title> 

but you'd better off setting title in viewmodel , not using viewbag.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -