Upload media to virtual directory: "startIndex cannot be larger than length of string"
I downloaded Umbraco 4.8 and unpacked it on my box, created a site in IIS (.NET 4.0, integrated), everything works fine.
The I deleted the /media folder and added a virtual directory pointing to an other directory on the disk instead.
Whenever I try to upload an image, I get the following error:
startIndex cannot be larger than length of string. Parameter name: startIndex
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.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. Parameter name: startIndex
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.
In case others can benefit...
I was facing this exception in trying to add a media via IMediaService.CreateMedia()... and IMedia.SetValue().
Set Value was throwing "startIndex cannot be larger than length of string". My scenario is I am receiving files attached in http requests, and am looping over this.UmbracoContext.HttpContext.Request.Files to create Medias out of them in Umbraco. The stream I was providing to IMedia.SetValue was this.UmbracoContext.HttpContext.Request.Files["myFile"].InputStream.
I could not figure out what the problem was.
But - the process works if I use one of the other overloads of IMedia.SetValue. More specifically, the one that receives a HttpPostedFileBase object.
sometime works properly and other times throws the exception "startIndex cannot be larger than length of string"
After digging a little bit in the Umbraco source code it seems that the problem is the filename. The filename needs to have an extesion, if not so then the following statement will fail:
Upload media to virtual directory: "startIndex cannot be larger than length of string"
I downloaded Umbraco 4.8 and unpacked it on my box, created a site in IIS (.NET 4.0, integrated), everything works fine.
The I deleted the /media folder and added a virtual directory pointing to an other directory on the disk instead.
Whenever I try to upload an image, I get the following error:
startIndex cannot be larger than length of string.
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.Parameter name: startIndex
Exception Details: System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex
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:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
I tried the following:
I found this issue un codeplex: http://umbraco.codeplex.com/workitem/30937 but though I get the same error, my problem is not related to the browser.
Some people mentioned that I should use the web installer, but I don't see why that should change anything.
Is there a web.config setting I am missing? What are the steps to place the media outside of the web site root?
Looks like I can't update my post: Still not working, but adding a symbolic link
seems to work - I'm not yet sure what other problems this will create...
This may be linked to this issue: http://umbraco.codeplex.com/workitem/30947
Codeplex issues are gone, the issue was kindly migrated to the new issuetracker: http://issues.umbraco.org/issue/U4-626
Looks like the code responsible for this does not exists anymore. I'll check as soon as I get to upgrade a project...
In case others can benefit... I was facing this exception in trying to add a media via IMediaService.CreateMedia()... and IMedia.SetValue(). Set Value was throwing "startIndex cannot be larger than length of string". My scenario is I am receiving files attached in http requests, and am looping over this.UmbracoContext.HttpContext.Request.Files to create Medias out of them in Umbraco. The stream I was providing to IMedia.SetValue was this.UmbracoContext.HttpContext.Request.Files["myFile"].InputStream.
I could not figure out what the problem was. But - the process works if I use one of the other overloads of IMedia.SetValue. More specifically, the one that receives a HttpPostedFileBase object.
Hoping you could benefit from this too.
Avraham Kahana,
I got the same issue (Umbraco 7.2.4) and was wondering why the method
sometime works properly and other times throws the exception "startIndex cannot be larger than length of string"
After digging a little bit in the Umbraco source code it seems that the problem is the filename. The filename needs to have an extesion, if not so then the following statement will fail:
https://github.com/umbraco/Umbraco-CMS/blob/813f1a1f2dd83464ab557c9be8023ff13f255fe6/src/Umbraco.Core/Models/ContentExtensions.cs (line 524)
I hope that helps someone.
Thanks for sharing Alain!
Helped me too, thanks!
is working on a reply...