asp.net - "Length cannot be less than zero. Parameter name: length" when calling ASPX WebMethod in site using Sitecore -


i'm receiving "length cannot less zero. parameter name: length" errors when calling webmethod on plain asp.net webforms (aspx) page. error gives no clear idea (that can see) problem is, , both , post calls other webmethods similar signatures on page work.

i'm guess it's in sitecore causing problem.

the full error in response is:

 [argumentoutofrangeexception: length cannot less zero. parameter name: length]    system.string.internalsubstringwithchecks(int32 startindex, int32 length, boolean falwayscopy) +10929307    sitecore.web.requesturl.get_itempath() +138    sitecore.pipelines.httprequest.siteresolver.getitempath(httprequestargs args, sitecontext context) +32    sitecore.pipelines.httprequest.siteresolver.updatepaths(httprequestargs args, sitecontext site) +69    sitecore.pipelines.httprequest.siteresolver.process(httprequestargs args) +49    sitecore.support.pipelines.httprequest.siteresolver.process(httprequestargs args) +261    (object , object[] ) +59    sitecore.pipelines.pipelinemethod.invoke(object[] parameters) +36    sitecore.pipelines.corepipeline.run(pipelineargs args) +237    sitecore.pipelines.corepipeline.run(string pipelinename, pipelineargs args, string pipelinedomain, boolean failifnotexists) +158    sitecore.pipelines.corepipeline.run(string pipelinename, pipelineargs args, string pipelinedomain) +64    sitecore.pipelines.corepipeline.run(string pipelinename, pipelineargs args) +50    sitecore.nexus.web.httpmodule.(object , eventargs ) +450    system.web.synceventexecutionstep.system.web.httpapplication.iexecutionstep.execute() +136    system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +69 

my webforms page called "addresslookupservice.aspx:", located on root of site, , webmethod signature (i know it's nothing internal webmethod causing problem):

 [webmethod] [system.web.script.services.scriptmethod(usehttpget = false)] public static string searchaddressbyformattedadd(string formattedaddress, string sessiontoken) {     ... } 

i'm calling service basic jquery $.ajax() this:

 function calladdresslookup()  {     var result = null;      var url = "/addresslookupservice.aspx/searchaddressbyformattedaddress";     var postdata = { formattedaddress: "123 smith street", sessiontoken: "abc" };      $.ajax(         {             async: false,             url: url,             datatype: "json",             data: json.stringify(postdata),             type: "post",             contenttype: 'application/json; charset=utf-8',              success: function (datastring, textstatus, jqxhr)              {                 result = ...             },              error: function (jqxhr, textstatus, errorthrown)              {                 result = ...             }         });      return result; } 

the site 1 i've been brought in integrate new functionality , contains sitecore code , configuration. i'm not sitecore developer , don't know first thing it, , "patch , pray" type project (i'm working heavy javascript based ui , adding webmethods keep new functionality separated).

what causing error, , how can fix it/work around it?

note: see first answer quick-fix discovered.

since you're working sitecore try determine item of database matches requested url before resolving looking on disk. itemnames in sitecore have maximal length (which setting can find in config files). if page name longer maximum length run issue believe.

if want work outside of sitecore using webmethods i'd advise setup proper .svc or .asmx host json data instead of using .aspx files. cause sitecore leave urls alone. if need access sitecore data inside of these services leave comment , i'll point right posts here on stackoverflow.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -