Ad

SEO Meta Tags From Behind Code - C#

- 1 answer

I'm new to adding meta tags from behind code, but if SEO Meta Tags were added from behind code,from a database for example, will they work as they were added in the markup from the beginning?

If so, where should I create them? Page_PreRender, Page_Init,..etc.

Thanks in advance.

Ad

Answer

Server will render your page to client(browser, search engine crawler)

It is better add it to your page's template, your Razor file or aspx file.

if you do want to add it to you page. you could add it to Page_Load, Page_Render or Page_Pre_Render

E.g.

I will add below to my _Layout.cshtml file or similar code to master page template.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    @if (Page.NeedAdditionMeta)
    {
        <meta name="m1" content="xxx" />
        <meta name="m2" content="yyy" />
        <meta name="m2" content="zzz" />
    }
Ad
source: stackoverflow.com
Ad