You will need to paste this into a base page or a master page and then simply call it when needed.
public void InsertCanonical(string canonicalUrl)
{
//if no url was specified just make the canonical the exact url of this page minus querystring
//i'm also removing the default.aspx which you most likely wont need to access this page
if (string.IsNullOrEmpty(canonicalUrl))
{
canonicalUrl = "http://" + Request.Url.Host + Request.Url.AbsolutePath.Replace("default.aspx", "");
}
//if there is a relative url is provided (i.e. host is NOT provided) add it in plus http protocol
else if (!canonicalUrl.Contains("www.YOURSITE.com"))
{
canonicalUrl = "http://" + Request.Url.Host + canonicalUrl;
}
//if the canonical does NOT begin with either http or https protocol add it in
else if(!Regex.Match(canonicalUrl, "^https?://").Success)
{
canonicalUrl = "http://" + canonicalUrl;
}
//create the canonical link and add it to the page headers :)
var link = new HtmlLink();
link.Href = canonicalUrl.ToLower();
link.Attributes.Add("rel", "canonical");
Header.Controls.Add(link);
}
{
//if no url was specified just make the canonical the exact url of this page minus querystring
//i'm also removing the default.aspx which you most likely wont need to access this page
if (string.IsNullOrEmpty(canonicalUrl))
{
canonicalUrl = "http://" + Request.Url.Host + Request.Url.AbsolutePath.Replace("default.aspx", "");
}
//if there is a relative url is provided (i.e. host is NOT provided) add it in plus http protocol
else if (!canonicalUrl.Contains("www.YOURSITE.com"))
{
canonicalUrl = "http://" + Request.Url.Host + canonicalUrl;
}
//if the canonical does NOT begin with either http or https protocol add it in
else if(!Regex.Match(canonicalUrl, "^https?://").Success)
{
canonicalUrl = "http://" + canonicalUrl;
}
//create the canonical link and add it to the page headers :)
var link = new HtmlLink();
link.Href = canonicalUrl.ToLower();
link.Attributes.Add("rel", "canonical");
Header.Controls.Add(link);
}
Most times you simply want to use pass null as the parameter just to truncate some ugly tracking querystring paramters off of your URL. So you may appreciate this override too:
public void InsertCanonical()
{
InsertCanonical(null);
}
{
InsertCanonical(null);
}
if there is a relative url is provided (i.e. host is NOT provided) add it in plus http protocol. NS0-160 dumps
ReplyDeleteThe look rightly terrific. All these mini advice happen to be created implementing massive amount past working experience. I'd like to see the whole works very much. los angeles colocation
ReplyDeleteI have read your Article and found it interesting
ReplyDeleteYour code is actually working and It is useful for SEO
of a website
I have my website blog regarding Technology and jobs
Top 10 Best ways to create a
Unique Blog and Index it
easily on Search Engine
SEO Tools for indexing a Blog
If you have created a Blog Website on your
favorite Niche.
Afterward, you have to write an article
/Blog on your selected Topic.
Be Aware Use Custom Domain Name.
If you are using Domain of default
Blogger.com default domain is
.blogspot.com then you may not get
proper page ranking and also
you are not eligible for Google
Adsense Approval.
So try to use from the following lists
List of Top-Level Domains
Click here :
Next Point is About Security Certificate https://
Try to use include https: instead of http:
Blogger.com Basically provide SSL
certificate by default.
If you are using any other platform for
creating a website then you have to purchase
a certificate for getting https.
https websites are secure and easily
rank and index in search engine as
compared to websites with http.
While Writing Blog remember not to
do copy/paste content from here and
There.
Only you can use reference for your
selected topic /subject but the content
should be yours.
There are many websites available on
the internet where you can check
your blog content.
Few among them are :
https://plagiarismdetector.net/
https://www.duplichecker.com/
https://www.quetext.com/
Use anyone among them for
checking your content online
for free.
Above mentioned websites allow
you to paste your code in the
given box and then click on
check plagiarism.
wait for 5 minutes and your
the result will be displayed.
check if your content copy write
the issue in percentage is above 90%
Then it’s ok but if less than 90%
Then you have to modify your
content and check it again.
You can check many times so
that you satisfy that your content
is Unique Now.
Unique content chances for ranking
is more and also for Google Adsense
Approval It is a desirable condition.
Otherwise, You will never get
Google Adsense Approval
if you are interested in reading more please visit
my website /Blog
https://www.careerjobtech.com/2020/07/10-best-ways-to-create-unique-blog_25.html
Thanks
Admin
careerjobtech.com
I have read your Article and found it interesting
ReplyDeleteI have my website blog regarding Technology and jobs
As a Blogger, Webmaster or SEO Expert, we all want that whenever people search for something related to our website (or about which we write on our blog) then our website is the first person to be seen at the top of Google.
So that more and more people can click on it and our website can be visited by many users World Wide.
There are several small techniques to get these gestures to Google that are called "search engine optimization (SEO)" when used together.
The full form of SEO is 'SEARCH ENGINE OPTIMIZATION'.
SEO is not a single technique but it is a combination of many different techniques, with the help of which you can show your website first on Google.
Now further we are going to know about these SEO Techniques-
What is SEO and how to do SEO of a website
It is clear that from the first page of Google, most people visit a website.
That is, if it is said broadly, the more people who click on the website (or say rank) in Google, the more people click on it and the more is the users on the web.
Now, which blogger does not want his blog to be a lot of traffic, And he became popular.
Everyone wants his blog to be converted into a high-traffic blog.
But now everything is not possible only by wanting.
You have to work hard to reach your desires to the destination.
To bring good and consistent traffic to your website, you have to rank your website in a good position in Google.
But now Google does not pick up a website and elevate it in its search.
He ranks only those websites that give accurate answers to the questions asked by people and serve value to Searchers.
» To locate good websites, Google conducts very in-depth SEO Techniques investigations of them as it finds out-
1) • Someone who is a website, how old it is (Domain Age) - Older website = more good ranking.
2) • How many words are the post written on it (Word Count).
3) • Do the words Title, Heading, Subheading, Bold, Italic, and Underline of that post are written by the person who searched in Google.
(Keywords) more correct keywords = more good ranking
if you are interested in reading more please visit
my website /Blog
https://www.careerjobtech.com/2020/06/seo-techniques-importance-for-website.html
Thanks
Admin
careerjobtech.com