If you don't want FilePath based language resolving, simple do below setting in Sitecore.config:
<setting name="Languages.AlwaysStripLanguage" value="false" />
This will do nothing but ignoring the StripLanguage processor from preprocessRequest pipeline.
By default first item (after domain name), Sitecore checks whether it's a language or not. If it'...
Props to @rosscartwright, @cassidydotdk, and @jammykam for getting us to the answer at lightning speed and for the helpful links.
The issue was a feature of Sitecore called AlwaysStripLanguage that is controlled by a Sitecore Setting in the Language group that controls the activation of a processor in the <preprocessRequest /> pipeline called Sitecore....
For your request you can use Display name functionality
Display names can include characters not allowed in item names.
Display names can vary by language, where item names cannot.
Because display names can vary by language, and item URLs can contain display names rather than item names, URLs for individual items can vary by language (beyond hostname, ...
From what I can tell your exception says in fact that you passed null MediaItem to GetMediaUrl method.
It looks like you have a field ImageField imageItem but imageItem.MediaItem is null. It's either not selected or the media item is not published.
Add extra check to your code to render a url only when imageItem.MediaItem is not null:
var titleUrl = ...
In general, when using the out of the box functionality and fields , you can specify the display name to any value you like for the URL. It appears you have already configured your Link Provider to use display names so that part is done.
A common approach would then be to introduce a Page Title field. It is very common that the text for a title may not ...
You need to block them. Ideally, Google should never have been told about these URLs in the first place, it looks like you might have some mismanaged Site Url Generation going on elsewhere.
But for purposes of getting these links OFF Google again, you need to block them. Easiest way to do it, is to use a Rewrite rule. Something like:
From what I remember, if you add an image from media library into RTE field, Sitecore uses the following format:
<img src="-/media/5EA5C007FFFF4688A0B7E6F58B79D2E8.ashx" />
With your media item id instead of 5EA5C007FFFF4688A0B7E6F58B79D2E8.
Try to use the same format from your code instead of generating the url using MediaManager.
Then the url ...
ItemSearchLinkProvider is a very simple provider with GetItemUrl method which:
Checks if item is inside a bucket
If no it returns base.GetUrl - where base class is Sitecore.Links.LinkProvider
If yes, it generates url in a format:
This may happen when you have a sibling item (e.g. folder or item without a layout) with the same name or display name.
Be aware that Sitecore replaces hyphens to spaces when it tries to find an item in the tree, so if your url is customer-care-support you have a sibling with a name customer
care support next to your customer-care-support item, you can ...
I don't know of an ootb solution, this is how I usually "fix" this issue:
Add a setting to the site definition that lists all available languages
Add a a processor to the httpRequestBegin pipeline after the language resolver:
<processor patch:after="*[@type='Sitecore.Pipelines.HttpRequest.LanguageResolver, Sitecore.Kernel']" ...
This is how Sitecore works with item resolving. It will resolve via Item Name or Display Name. Setting the useDisplayNames in the LinkProvider will have zero effect on how Sitecore resolves the item names.
In the ItemResolver the code calls tries to resolve the item by the Item Name first, then if it can't do that it calls this method:
You can get item by URL using below function. You may have to tweak it for resolving wildcard items.
$url = [System.Uri]::new($url);
$siteContext = [Sitecore.Sites.SiteContextFactory]::GetSiteContext($url.Host, $url.PathAndQuery);
$homePath = $siteContext.StartPath;
The update in Sitecore 9.3 adds the new itemUrlBuilder configuration to control how item and media URLs are built. Unfortunately, this in not wired into the IoC container (unlike the LinkManager itself for example). The Sitecore documentation states:
The default Sitecore implementation of the BaseLinkManager class uses the Sitecore.Links.LinkProvider class. ...
From what I understand, you want to implement custom logic for generation of internal links added by content authors in Rich Text fields.
If that's the case, you need to change the logic of renderField pipeline and its ExpandLinks processor.
By default this processor calls DynamicLink.ExpandLinks(...) method.
You would need to replace that with your custom ...
You can override UrlAgent that is used to make keepalive.aspx call. And disable certificate validation:
((sender, certificate, chain, sslPolicyErrors) => true);
It is configured in Sitecore.config:
<agent type="YourNamespace.YourUrlAgent" method="Run" interval="00:15:...
The problem you are trying to solve, rendering the full URL with host name, does not require a custom link provider since this behaviour is available out of the box.
There are 2 settings which control this, both of which are true by default in 9.3 (they have been true for a number of versions).
<!-- SITE RESOLVING
While rendering item links, some ...
You won't be able to do this with an ootb alias and customizing that code just for a querystring seems a bit overkill. Why not use redirects?
There is a redirect module on the marketplace (https://marketplace.sitecore.net/Modules/3/301_Redirect_module.aspx?sc_lang=en) that can help. This one can redirect to an item or a url, which can include a querystring....
You could use Sitecore wildcard item(s) to achieve this.
You create a page underneath searchpage and name it "*". Sitecore will map all request that are made to something underneath searchpage (and can't be resolved) to this wildcard item.
The wildcard item itself is actually an item just like any other - so you can put a layout and renderings on it. In ...
Synthesis has an extension method for ImageFields called RenderDpiAware (link) that allows you to specify a bunch of sizes to be used in a CSS source set.
Additionally, the Render() extension method (link) on ImageFields has the ability to set a max width and max height. In a razor view, it would look like:
@Model.YourImageField.Render(maxWidth: 100, ...
If you only want to refresh the querystring and nothing else, you don't have to write the url for the current page, you can just write the querystring part:
click <a href="?test">here</a> to set the querystring to "?test" in your current url
If for some reason you still want to add the current url to the link though, you can do it by either ...
targetHostName attribute is used to generate URLs from linkManager when SiteResolving is set to true.
The host name to use when generating URLs to items within this site
from the context of another site. If the targetHostName attribute is
not available, Sitecore uses the value of the hostName attribute
instead. The attribute is only used when the ...
you have to use MediaUrlOptions and to pass it to GetMediaUrl method.
You will have:
var image = new MediaItem(imageField.MediaItem);
MediaUrlOptions mediaUrlOptions = new MediaUrlOptions();
mediaUrlOptions.AlwaysIncludeServerUrl = true;
string src = Sitecore.StringUtil.EnsurePrefix('/', Sitecore.Resources....
Sounds like Java Server Pages. Sitecore is based on .Net and doesn't use this page extension. That is why I assume that it could be added by some external sitemap(it is a built-in feature of SXA).
I suggest you check external sitemap settings for your SXA website:
Open Settings item under your root SXA website
Look for &...
If you take a look at the current implementation of the SitemapGenerator service in Sitecore.XA.Feature.SiteMetadata.dll, there is a method GetFullUrl which renders the url in the sitemap
protected virtual string GetFullLink(Item item, SitemapLinkOptions options)
string itemUrl = LinkManager.GetItemUrl(item, options.UrlOptions);
It turned out to be that there were two images with the same path / name. One was a jpg and one was a png.
Because we're using paths instead of IDs for the image URLs, Sitecore seems to have trouble resolving the correct image. It was loading the jpg instead and applying the default black background color because it was a jpg.
There can be several reasons why you are seeing this weird behavior. Some of them are listed below:
Is it happening for all the pages?
If yes, you need to check the sitedefinition.config
Does the page have a Layout and rendering. If not, you need to make sure that the page has a valid layout and renderings associated so that it can be visible in front end.
ASP.NET implements various algorithms for securing ASP.NET websites against potentially malicious user requests, for example, by rejecting requests that contain characters susceptible to be used in XSS attacks, suspiciously long request paths, etc.
When potentially malicious requests hit a Sitecore website, they would result in different errors either shown ...
I would suggest to use the encodeNameReplacements in the web.config
This is the default set:
<replace mode="on" find="&" replaceWith=",-a-," />
<replace mode="on" find="?" replaceWith=",-q-," />
<replace mode="on" find="/" replaceWith=",-s-," />
<replace mode="on" find="*" replaceWith=",-w-...
This happens because your context site is "shell" .
You need to switch to website site using :
using (new SecurityDisabler())
var item = mediaCreator.CreateFromStream(ms, fileName, options);
using (new SiteContextSwitcher(Factory.GetSite("website")))
var uri = MediaManager.GetMediaUrl(item);