bobek
bobek

Reputation: 8020

asp.net mvc 3, add <meta /> to <header> from any part of application

My question is: How can I add meta tag from my view or partial view? Basically I want to, from the view, write a meta tag, and I want it to be displayed in the header. Is it possible?

Thank you H

Upvotes: 3

Views: 1292

Answers (1)

Adam Flanagan
Adam Flanagan

Reputation: 3052

You can use sections to do this.

In you layout page you need to define the section:

<head>
    @RenderSection("Head", required: false)
</head>

This section can then be used in any page that uses this layout page:

@section Head {
    <meta ... >
}

Upvotes: 6

Related Questions