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.
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;
}
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:
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.
Hi Michael, I know this, but I expecting this error have nothing with urls :-o
Try look here:
http://vaultofthoughts.net/InvalidURITheUriSchemeIsTooLong.aspx
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.
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/
Hi, I know that, but I have not bitbucket account ...
Here is my modification
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
You can find sources on second tab (Resources) of project page.
Here is direct link https://bitbucket.org/reboot/embedded-content-umbraco
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
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
is working on a reply...