The last part of http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Routing/Routing/ describes how you can configure your site to allow longer urls
I've tried adding <httpRuntime maxUrlLength="1024" relaxedUrlToFileSystemMapping="true"/> under <configuration><system.web> in Web.config without any luck. Any other ideas?
Any progress?
AFAIK, the maxUrlLength setting is not connected to the MaxLength property of the PropertyUrl class, the 255 character maxlength is inherited from the PropertyString class.
After further investigation, it seems the only way is to override the MaxLength property of the PropertyData implementation.
One way to do it is to create a custom backing type, like this.
[PropertyDefinitionTypePlugIn, Serializable] public class PropertyUrlWithLength : PropertyUrl { public override int MaxLength { get { var section = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection; return section?.MaxUrlLength ?? base.MaxLength; } set { // Cannot set from code. } } }
And then, on your property declare it like thus:
[Display(Order = 11), BackingType(typeof(PropertyUrlWithLength))] public virtual Url ButtonUrl { get; set; }
My example uses Johans suggested configuration change to set the length, however, that might not be what you want.
Hi there,
Did anyone get any solution this?
I tried all the above solutions and some more by editing web config with following settings. Also added a custom backing type and still the max length of characters I can put in the remaining Url field of Episerver Url property is 407. Need help understanding what am I missing here -
<httpRuntime targetFramework="4.6.1" requestValidationMode="2.0" enableVersionHeader="false" maxRequestLength="51200" executionTimeout="300" maxUrlLength="10240" relaxedUrlToFileSystemMapping="true" maxQueryStringLength="2097100" />
also tried maxUrlLength - 1024/2048 & maxQueryStringLength-65536 but same output!!
also based on some other references tried below -
<requestFiltering>
<requestLimits maxUrl="30000" maxQueryString="209007151" maxAllowedContentLength="204800000" />
</requestFiltering>
nothing so far!!!
I was able to solve this issue for CMS version 11.14. Described below is the approach, I used.
[PropertyDefinitionTypePlugIn, Serializable]
public class LongUrl : PropertyUrl
{
public override int MaxLength { get; set; } = 2048;
}
I am overridding max length value to 2048. Default is 255.
2. Create a backing type
[Display(GroupName = SystemTabNames.Content, Order = 10)]
[BackingType(typeof(LongUrl))]
public virtual Url Url { get; set; }
@Tanuj: That won't work for URLs above 450 characters, due to the database max length (which may or may not be an issue for you depending on your actual URL requirements).
Proposed a solution here: https://world.episerver.com/forum/developer-forum/Developer-to-developer/Thread-Container/2020/5/how-to-increase-remaining-url-length-of-episerver-url-link-type-/
Hi,
I'm getting the following error when adding an external URL in edit mode that is longer than 255 chars:
Could not save property, and it has been reverted. Please try again.
"Src" has exceeded its limit of 255 characters.
Logfile:
I wonder if it is possible to allow Url's that are longer than 255 chars?
Thanks!