开发者

MVC3 Master Page RenderSection on HEAD

开发者 https://www.devze.com 2023-03-24 02:52 出处:网络
I have the following code in my master page (_Layout.cshtml): //Html tag and config <head> &开发者_如何学Pythonlt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />

I have the following code in my master page (_Layout.cshtml):

//Html tag and config
<head>
    &开发者_如何学Pythonlt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="content-language" content="es" />
    <meta http-equiv="Pragma" content="no-cache" />

    @RenderSection("FacebookMetaTag", false)
</head>

Then, in my Home/Index.cshtml I have:

@model Domain.Entities.Product


@section FacebookMetaTag {
        <meta property="og:title" content="@Model.Name"/>
        <meta property="og:type" content="Mycompany"/>
        <meta property="og:url" content="@Model.Url"/>
        <meta property="og:image" content="@Model.Image"/>
        <meta property="og:site_name" content="Mysite"/>
        <meta property="fb:admins" content="USER_ID"/>
        <meta property="og:description"
              content="Model.Description"/>
}

....//Some other stuff....

When I run my application the FacebookMetaTag section is not in my master page. Why? what can I do?

Thanks in advance


I am going to take a guess that your _ViewStart.cshtml is not properly configured; can you post the code?

Secondly, does the rest of the HTML get outputted?

Matt


Head is not rendered only the body renders. So you cannot add @RenderSection inside head tag.

0

精彩评论

暂无评论...
验证码 换一张
取 消