Avatar of searchei68
searchei68

asked on 

ASP.net Meta tag rendering

How do you get the meta tags to be the first items rendered within the <head> tag in an asp.net page?

I have tried this on the page load event

        HtmlHead head = (HtmlHead)Page.Header;

        lt.Text = NL + NL;
        head.Controls.Add(lt);
        hm.Name = "keywords";
        hm.Content = "mykeywords";
        head.Controls.Add(hm);
        hm = null;

        hm = new HtmlMeta();
        lt = null;
        lt = new Literal();
        lt.Text = NL;
        head.Controls.Add(lt);
        hm.Name = "description";
        hm.Content = "bla bla bla.";
        head.Controls.Add(hm);

But it still renders like the attached HTML code

It there a way to control the order this is rendered?

Thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="App_Themes/Aqua/Web/styles.css" />
<link rel="stylesheet" type="text/css" href="App_Themes/Aqua/Editors/styles.css" />
<link rel="stylesheet" type="text/css" href="/MySite.net/WebResource.axd?d=wAo6zMHVDKH7rB7xoxMdw7ISZfNDhHX3egRvnjJqATpwUjt2NNIHZnAME7BdKe2H62RpxAnn-h-w69zdrX_eI03s1JEOuTD-wKEpeiAWSnaHxBffeuPWQQeXSos41wv_u36Qb6SdtaTBN8LMyk-fgg2&amp;t=633702933191316492" />
 
 
<style type="text/css">
 
span.FootnoteCharacters
	{vertical-align:super}
span.MsoFootnoteReference
	{mso-style-parent:"";
	vertical-align:super;}
h1{
	margin-bottom:.0001pt;
	text-align:justify;
	text-indent:0cm;
	page-break-after:avoid;
	tab-stops:list 0cm;
	font-size:16.0pt;
	font-family:"Tahoma";
	margin-left:0cm; margin-right:0cm; margin-top:0cm}
	
h2{
	margin-bottom:.0001pt;
	text-align:justify;
	text-indent:0cm;
	page-break-after:avoid;
	tab-stops:list 0cm;
	font-size:14.0pt;
	font-family:"Tahoma";
	margin-left:0cm; margin-right:0cm; margin-top:0cm}
 
 
.dxnbControl_Aqua 
{
	font: 9pt Tahoma;
	color: #283B56;
	background-color: #F2F8FF;
	padding: 0px;    
}
.dxnbGroupHeader_Aqua, .dxnbGroupHeaderCollapsed_Aqua
{
    text-align: left;
}
.dxnbGroupHeader_Aqua
{
	font: 9pt Tahoma;
	color: #283B56;
	background-color: #F2F8FF;
	border: Solid 1px #AECAF0;
	padding: 4px 4px 4px 8px;
	
	background-image: url('App_Themes/Aqua/Web/nbGroupHeaderBack.gif');
	background-repeat: repeat-x;
	background-position: 50% top;
    }
.dxnbGroupContent_Aqua
{
	font: 9pt Tahoma;
	color: #F2F8FF;
	border: Solid 1px #AECAF0;
	padding: 1px;
}
.dxnbItem_Aqua, .dxnbItemHover_Aqua, .dxnbItemSelected_Aqua,
.dxnbBulletItem_Aqua, .dxnbBulletItemHover_Aqua, .dxnbBulletItemSelected_Aqua
{
    text-align: left;
}
.dxnbItem_Aqua
{
	padding-top: 5px;
	padding-right: 15px;
	padding-bottom: 6px;
	padding-left: 15px;
}
.dxnbItem_Aqua, .dxnbLargeItem_Aqua, .dxnbBulletItem_Aqua
{
	font: 9pt Tahoma;
	color: #283B56;
	background-color: #F2F8FF;
    border-top: Solid 1px #F2F8FF;	
    border-bottom: Solid 1px #F2F8FF;	
}
    .style1
    {
        width: 328px;
    }
    .style2
    {
        width: 700px;
    }
    .style3
    {
        width: 100%;
    }
    -->
 
</style>
 
 
 
 
 
<meta name="keywords" content="MyKeyword" />
<meta name="description" content="MyKeywordprotects you on the Internet.  Choosing the right MyKeyword is imperative in securing your identity." />
<meta name="Robots" content="ALL" />
<meta name="distribution" content="global" />
<meta name="author" content="mywebsite.net" />
<meta name="copyright" content="&amp;reg; 2009 MySite.net" />
 
<title>
	<b>MyTitle</b>
</title></head>

Open in new window

ASP.NET.NET ProgrammingMicrosoft Development

Avatar of undefined
Last Comment
Tony McCreath

8/22/2022 - Mon