Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Petr Snobelt 923 posts 1535 karma points
    Aug 12, 2011 @ 13:12
    Petr Snobelt
    0

    about 50 items

    Hi,

    I have problem with embeded control, which has more then about 50 items in it. It looks like there is problem with reading too much xml. I hope I can fix it myself, but I have no access to sources :-(

    Petr

    Stacktrace:

    Invalid URI: The Uri string is too long.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.UriFormatException: Invalid URI: The Uri string is too long.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace: 

    [UriFormatException: Invalid URI: The Uri string is too long.]
       System.Uri.EscapeString(String input, Int32 start, Int32 end, Char[] dest, Int32& destPos, Boolean isUriString, Char force1, Char force2, Char rsvd) +97
       System.Uri.EscapeDataString(String stringToEscape) +100
       TheFarm.Umbraco.EmbeddedContent.EmbeddedContent.MergeValueWithXmlSchema() +4262
       TheFarm.Umbraco.EmbeddedContent.EmbeddedContent.LoadControlsAndData() +99
       TheFarm.Umbraco.EmbeddedContent.EmbeddedContent.OnLoad(EventArgs e) +70
       System.Web.UI.Control.LoadRecursive() +71
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048

     

     

     

  • Michael Latouche 502 posts 816 karma points MVP c-trib
    Aug 12, 2011 @ 13:22
    Michael Latouche
    0

    Hi Petr,

    You can modify the max query string length in the web.config (if you have access to that file):

    <configuration>
       
    <system.webServer>
           
    <security>
               
    <requestFiltering>
                   
    <requestLimits
                        maxAllowedContentLength
    ="30000000"
                        maxUrl
    ="260"
                        maxQueryString
    ="25"/>
               
    </requestFiltering>
           
    </security>
       
    </system.webServer>

    See http://stackoverflow.com/questions/2977777/limit-url-parameter-length-in-web-config and http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits for more info.

    Hope this helps.

    Cheers,

    Michael.

  • Petr Snobelt 923 posts 1535 karma points
    Aug 12, 2011 @ 13:29
    Petr Snobelt
    0

    Hi Michael, I know this, but I expecting this error have nothing with urls :-o

    Try look here:

    http://vaultofthoughts.net/InvalidURITheUriSchemeIsTooLong.aspx

     

  • Petr Snobelt 923 posts 1535 karma points
    Oct 08, 2012 @ 21:21
    Petr Snobelt
    0

    It looks like source string can't exceed 32766 characters :-( 

    Some more info http://stackoverflow.com/questions/6695208/uri-escapedatastring-invalid-uri-the-uri-string-is-too-long

    Encoding each item separately should help.

     

     

     

  • Jeavon Leopold 3020 posts 13310 karma points MVP 8x admin c-trib
    Oct 15, 2012 @ 12:51
    Jeavon Leopold
    0

    Hi Petr, you might know already but just in case you don't, the source code for embedded content v1.2 can now be found at https://bitbucket.org/reboot/embedded-content-umbraco/

  • Petr Snobelt 923 posts 1535 karma points
    Oct 15, 2012 @ 20:18
    Petr Snobelt
    0

    Hi, I know that, but I have not bitbucket account ...

    Here is my modification

            /// 
            /// Builds up the proper value xml for the hidden field, merged with the schema.
            /// 
            /// Note Uri.EscapeDataString don't work for long strings, so each item is escaped separately
            /// Fix for http://our.umbraco.org/projects/backoffice-extensions/embedded-content/bugs/23064-about-50-items?p=0#comment128102
            /// More info http://stackoverflow.com/questions/6695208/uri-escapedatastring-invalid-uri-the-uri-string-is-too-long
            private void MergeValueWithXmlSchema()
            {            
                var schema = new XmlDocument();
                schema.LoadXml(Uri.UnescapeDataString(_hiddenXmlSchema.Value));
    
                var plainValue = new XmlDocument();
                plainValue.LoadXml(Value);
    
                var sbValue = new StringBuilder();
                sbValue.Append(Uri.EscapeDataString(""));
    
                if (plainValue.DocumentElement != null && schema.DocumentElement != null)
                {
                    //get the schema in a more usable condition
                    var attributes = GetAttributesDictionary(schema);
    
                    foreach (XmlNode itemNode in plainValue.DocumentElement.ChildNodes)
                    {
                        if (itemNode.Attributes != null)
                        {
                            var sbItem = new StringBuilder();
                            sbItem.Append(string.Format("", itemNode.Attributes["id"].Value));
    
                            foreach (XmlNode propertyNode in itemNode.ChildNodes)
                            {
                                if (propertyNode.Attributes != null && propertyNode.Attributes["propertyid"] != null)
                                {
                                    var id = propertyNode.Attributes["propertyid"].Value;
                                    sbItem.Append(string.Format("");
                                    sbItem.Append(System.Web.HttpUtility.HtmlEncode(propertyNode.InnerText));
                                    sbItem.Append(string.Format("", propertyNode.Name));
                                }
                            }
                            sbItem.Append("");
                            sbValue.Append(Uri.EscapeDataString(sbItem.ToString()));
                        }
                    }
                }
    
                sbValue.Append(Uri.EscapeDataString(""));
                Value = sbValue.ToString();
            }
    
            private static Dictionary GetAttributesDictionary(XmlDocument schema)
            {
                Dictionary attributes = new Dictionary();
    
                foreach (XmlNode property in schema.DocumentElement.ChildNodes)
                {
                    var sbAttribute = new StringBuilder();
                    if (property.Attributes != null && property.Attributes.Count > 0)
                    {
                        var id = "";
                        foreach (XmlAttribute xmlAttribute in property.Attributes)
                        {
                            if (xmlAttribute.Name == "propertyid")
                            {
                                id = xmlAttribute.Value;
                            }
                            else if (xmlAttribute.Name != "description" &&
                                xmlAttribute.Name != "name" &&
                                xmlAttribute.Name != "require" &&
                                xmlAttribute.Name != "validation")
                            {
                                if (!string.IsNullOrEmpty(xmlAttribute.Value))
                                {
                                    sbAttribute.Append(" " + xmlAttribute.Name + "=\"" + xmlAttribute.Value + "\"");
                                }
                            }
                        }
                        attributes.Add(id, sbAttribute.ToString());
                    }
                }
                return attributes;
            }
    
    
    
  • nickornotto 341 posts 723 karma points
    Mar 08, 2013 @ 17:43
    nickornotto
    0

    Hi Petr,

    Where did you put your fix?

    I have the same problem with embedded content but have no source code for this plugin.

    I have no idea where to use your fix.

    Thanks

  • Petr Snobelt 923 posts 1535 karma points
    Mar 08, 2013 @ 20:46
    Petr Snobelt
    0

    You can find sources on second tab (Resources) of project page.

    Here is direct link https://bitbucket.org/reboot/embedded-content-umbraco

  • nickornotto 341 posts 723 karma points
    Mar 11, 2013 @ 12:29
    nickornotto
    0

    Thanks, I got the project, made a change a compiled. However simple replacing EC dll doesn't work.

    How can I add the fix to my Umbraco instalaltion? Sorry for the question but never had a chance to do it before. Thanks

  • Anton Oosthuizen 203 posts 483 karma points
    Feb 11, 2014 @ 12:42
    Anton Oosthuizen
    0

    Hi All

    I believe this problem hasn't been fixed

    I have a property value greater than 35k

    and I'm getting the same error

    Regards

Please Sign in or register to post replies

Write your reply to:

Draft