Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
how do I get @Request.Url.Scheme, @Request.Url.Host in Umbraco 11?
I saw some some discussions on stackoverflow that it was depreciated in .NET core
For example, in one answer they suggest to use
var url = httpContextAccessor.HttpContext?.Request?.GetDisplayUrl();
but I'm not sure how to get in Umbrco @Request.Url.Scheme, and @Request.Url.Host
I need for the social media tags - this is my Umbraco 7 code:
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage @{ var home = Model.AncestorOrSelf(1); var ogType = "article"; string ogImage = string.Empty; if (Model.HasValue("articleImg")) { ogImage = String.Format("{0}://{1}{2}", @Request.Url.Scheme, @Request.Url.Host, @Umbraco.Media(CurrentPage.articleImg.ToString()).Url); } string TwitterHandle = ""; TwitterHandle = "@" + "opli"; <!--Facebook Open Graph--> <meta property="og:locale" content="en_US" /> <meta property="og:type" content="@ogType" /> <meta property="og:title" content="@Umbraco.Field("title")" /> <meta property="og:description" content="@Umbraco.Field("metaDescription")" /> <meta property="og:url" content="@Request.Url" />
Thanks
inject IHttpContextAccessor and do something like
var urlRequest = _httpContextAccessor.HttpContext.Request;
You can then use
urlRequest.Scheme urlRequest.Host
Thank you so much :)
It works now!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
@Request.Url.Scheme, @Request.Url.Host in Umbraco 11
Hi,
how do I get @Request.Url.Scheme, @Request.Url.Host in Umbraco 11?
I saw some some discussions on stackoverflow that it was depreciated in .NET core
For example, in one answer they suggest to use
but I'm not sure how to get in Umbrco @Request.Url.Scheme, and @Request.Url.Host
I need for the social media tags - this is my Umbraco 7 code:
Thanks
inject IHttpContextAccessor and do something like
You can then use
Thank you so much :)
It works now!
is working on a reply...