本文介绍了强制Sitecore处理对文件的任何请求(。*)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 如何强制Sitecore处理任何文件请求,而不是从IIS获取404。 原因是,我们希望能够应用URL重写模块( http:// github.com/ParTech/Url-Rewriter )提交请求。How could one go about forcing Sitecore to handle any file requests, instead of getting a 404 from the IIS.The reason being, that we want to be able to apply the URL Rewrite Module (http://github.com/ParTech/Url-Rewriter) to file requests aswell.示例:用户请求: http://sitecore.domain/randomfolder/file.pdf (存在哪个剂量)Example:User requests : http://sitecore.domain/randomfolder/file.pdf (which dosent exists)但是我们希望Sitecore获取请求并应用任何重写规则(如果可用),而不是获取IISHTTP错误404.0 - 通过StaticFile找不到,而是使用Sitecore notfound页面。But instead of getting the IIS "HTTP Error 404.0 - Not Found via StaticFile", we want Sitecore to pick up the request, and apply any rewrite rules if available, else use the Sitecore notfound page.我尝试过将不同的处理程序添加到system.webserver但没有成功,以及在IIS设置上直接修改Handler Mappings。I've tried adding different handlers to system.webserver without success, aswell as directly modifying Handler Mappings on the IIS settings.推荐答案我不确定你是否应该去那里,因为所有的请求都会通过Sitecore,但是如果你想要它,你可以改变这个配置:I'm not sure if you should go there, because then all requests will go through Sitecore, but if you want it you can change this configuration: <preprocessRequest> <processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel"> <param desc="Allowed extensions (comma separated)">aspx</param> <param desc="Blocked extensions (comma separated)">*</param> <param desc="Blocked extensions that stream files (comma separated)">css,js</param> <param desc="Blocked extensions that do not stream files (comma separated)">*</param> </processor></preprocessRequest>将允许的扩展名设置为 * 并设置为已屏蔽空的扩展(未测试)。 如果你知道要重定向的扩展名(例如只是PDF文件),那么只能在允许的扩展名设置中定义那些(I建议你这样做。)Set allowed extensions to * and set blocked extensions to empty (not tested).If you know which extensions you are going to redirect (e.g. just PDF files), then only define those in the allowed extensions setting (I would suggest you do this).<param desc="Allowed extensions (comma separated)">aspx,pdf</param>我认为这是URL重写器模块处理请求所需的唯一内容。 请记住,该模块处理的文件请求未经测试且不受支持,但理论上它应该可以正常工作。I think that is the only thing needed for the request to be handled by the URL Rewriter module.Keep in mind that it's untested and unsupported for file requests to be handled by that module, but in theory it should work. 这篇关于强制Sitecore处理对文件的任何请求(。*)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-15 20:43