Sitecore Web服务URL长度

时间:2014-02-24 16:06:03

标签: sitecore

因此出于某种原因,sitecore似乎拒绝了此网址http://site1.com/sitecore%20modules/shell/service.svc/terms/a new term to find for all/的较长版本,但有错误:

[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
   System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +14652406
   Sitecore.Web.RequestUrl.get_ItemPath() +157
   Sitecore.Pipelines.HttpRequest.SiteResolver.GetItemPath(HttpRequestArgs args, SiteContext context) +55
   Sitecore.Pipelines.HttpRequest.SiteResolver.UpdatePaths(HttpRequestArgs args, SiteContext site) +88
   Sitecore.Pipelines.HttpRequest.SiteResolver.Process(HttpRequestArgs args) +75
   (Object , Object[] ) +83
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +191
   Sitecore.Nexus.Web.HttpModule.(Object , EventArgs ) +457
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

但网址http://site1.com/sitecore%20modules/shell/service.svc/terms/a new term to find/似乎运行良好。此外,当我在IgnoreUrlPrefix中添加网址时,它似乎完全丢失了网站核心上下文。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,如果我为webmethod选择一个简短的名称就可以了。使用长方法名称,我会得到与您相同的错误。

我没有找到这种行为的原因。    更新:

我向Sitecore支持部门询问了这个问题,然后他们发送了link

这是他们提供的代码:

 public class SiteResolver : SiteResolver
  {
    protected override void UpdatePaths(HttpRequestArgs args, SiteContext site)
    {
      if (!string.IsNullOrEmpty(HttpContext.Current.Request.PathInfo))
      {
        string filePath = args.Url.FilePath;
        int length = filePath.LastIndexOf('.');
        int num = filePath.LastIndexOf('/');
        args.Url.ItemPath = length >= 0 ? (length >= num ? filePath.Substring(0, length) : filePath) : filePath;
      }
      args.StartPath = site.StartPath;
      args.Url.ItemPath = this.GetItemPath(args, site);
      site.Request.ItemPath = args.Url.ItemPath;
      args.Url.FilePath = this.GetFilePath(args, site);
      site.Request.FilePath = args.Url.FilePath;
    }
  }

要正常工作,IgnoreUrlPrefixes不应包含Asxm webservice路径,并且siteresolver配置必须是:

   <processor type="Sitecore.Pipelines.HttpRequest.SiteResolver, Sitecore.Kernel">
      <patch:attribute name="type">yourNamespace.CustomSiteResolver,yourAssembly</patch:attribute>
    </processor>