How does Asp.net MVC output viewdata whose key is constant in the head tag of the ASPX page?
The following is valid:
<Meta name = "Description" content = "<%: viewdata [" pagedescription "] %>"/>
Put it directly in the head. valid:
<%: Viewdata [baseconstant. str_viewdata_pagedescription] %>
The following uses constants to replace "pagedescription"
Constant definition: Public const string str_viewdata_pagedescription = "pagedescription ";
Put the following statement in the body tag, and viewdata can be output normally:
<Meta name = "Description" content = "<%: viewdata [baseconstant. str_viewdata_pagekeyword] %>"/>
If the same statement is placed in the head label, viewdata cannot be output normally:
<Meta name = "Description" content = "<%: viewdata [baseconstant. str_viewdata_pagekeyword] %>"/>
The direct output is as follows:
<Meta name = "Description" content = "& lt; %: viewdata [baseconstant. str_viewdata_pagekeyword] %>"/>
Why? In the head label of the ASPX page, how does one output viewdata whose key is constant?
You can delete runat = "server" in the head label to use it.
Change from
<Head runat = "server">
<Meta name = "Description" content = "<%: viewdata [baseconstant. str_viewdata_pagekeyword] %>"/>
To
<Head>
<Meta name = "Description" content = "<%: viewdata [baseconstant. str_viewdata_pagekeyword] %>"/>
....
What is Microsoft doing ?? Why? Bug?
Since it is mvc4, why does runat = "server" be added to the head label when masterpage is created?