Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add meta tag to ASP.Net content page

Tags:

I have several content pages hanging off of one master page. I need to add a refresh meta tag to one of the content pages but I can't see where I can do this.

Any help would be much appreciated.

like image 301
doogdeb Avatar asked Jun 01 '11 09:06

doogdeb


People also ask

Where do I put meta tags in asp net?

The meta tag is placed between the opening/closing <head> </head> tags.

How do I add meta content?

If you want to add a meta tag to your website, search for instructions about modifying the <head> of your page on your CMS (for example, search for "wix add meta tags"). Use this tag to provide a short description of the page. In some situations, this description is used in the snippet shown in search results.


Video Answer


2 Answers

Have not tried this with refresh, but in general you can add a meta tag like this:

   var keywords = new HtmlMeta { Name = "keywords", Content = "one,two,three" };                 Header.Controls.Add(keywords); 

update: it is possible this way. Check Rick Strahl http://www.west-wind.com/weblog/posts/2006/Aug/04/No-more-Meta-Refresh-Tags

like image 113
Pleun Avatar answered Sep 19 '22 11:09

Pleun


This page explains the new feature: ASP.Net 4 adds 2 new Meta tag related properties to the Page. They can be used to set meta tags for keywords and description.

You can set them in the code behind:

Page.MetaKeywords = "keyword1, keyword2, keyword3"; Page.MetaDescription = "Example of new meta tag support in ASP.Net 4"; 

You can also set in the @Page directive:

<%@ Page Language="C#" AutoEventWireup="true" MetaKeywords="keyword1, keyword2, keyword3" MetaDescription="Example of new meta tag support in ASP.Net 4" CodeFile="Default.aspx.cs" Inherits="_Default" %> 

The ouput of either of these methods renders html similar to the following:

<!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>     <title>         ASP.NET 4 Meta Tag Support     </title>     <meta name="description" content="Example of new meta tag support in ASP.Net 4" />     <meta name="keywords" content="keyword1, keyword2, keyword3" /> </head> <body> </body> </html> 
like image 29
DOK Avatar answered Sep 22 '22 11:09

DOK