Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
my default meta tag
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
<meta name="viewport" content="width=device-width" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="twitter:card" content="summary">
<meta property="og:title" content="{TITLE}" />
<meta property="og:description" content="{DESCRIPTION}" />
<meta property="og:url" content="@Url.AppUrl()" />
<meta property="og:image" content="@Url.AppUrl()/Content/images/ogpimage.png" /><!-- The size of ogpimage.png is 120px x 120px. -->
<meta name="keywords" content="{KEYWORDS}" />
<meta name="description" content="{DESCRIPTION}" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="~/favicon.png" rel="icon" type="image/png" />
...
</head>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
public static class UrlHelperExtension
{
public static string AppUrl(this UrlHelper urlHelper)
{
var request = urlHelper.RequestContext.HttpContext.Request;
return request.Url.GetLeftPart(UriPartial.Scheme | UriPartial.Authority);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment