What is the difference if the head tag is runat or not?

When I create any views in my application in ASP.NET, I see that

<head runat="server">

If I change it to

<head>

What is the difference between these two conditions?

+3
source share
2 answers

If you define a tag headwith the attribute runatset to "server", the attribute value will be indicated Titlein the page declaration.

Suppose you define a page with the following declaration on top of the code:

MyPage.aspx:

<%@ Page title="My Website"...

Assume also that the homepage tag headis defined as follows:

Site.Master:

<head runat="server"></head>

Then the resulting markup will look like this:

<head><title>My Website</title></head>

head runat, , Title, , :

<head><title>My Website (Title has been set manually)</title></head>

: MVC Visual Studio, asp:ContentPlaceHolder Title :

<head runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
</head>

asp:ContentPlaceHolder Title, , Yngvebn

+3

URL-, src. , , , URL-.

/Foo /Foo/ /Foo/ /Baz

But your script src is "../scripts/script.js"

. , head runat = "server", ASP.NET , .

0

Source: https://habr.com/ru/post/1758663/


All Articles