因此,出于某种原因,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
中添加 url 时,它似乎完全丢失了站点核心上下文。
有什么想法吗?
我遇到了同样的问题,如果我为我的网络方法选择一个短名称就可以正常工作。 使用长方法名称,我得到与您相同的错误.
我没有找到为什么会有这种行为的原因。 更新:
我向 Sitecore 支持部门询问了此问题,他们向我发送了此链接。
这是他们提供的代码:
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;
}
}
要正常工作,IgnoreUrl前缀不应包含 Asxm Web 服务路径,并且站点解析器配置必须为:
<processor type="Sitecore.Pipelines.HttpRequest.SiteResolver, Sitecore.Kernel">
<patch:attribute name="type">yourNamespace.CustomSiteResolver,yourAssembly</patch:attribute>
</processor>