Asp.net mvc 不带扩展名的ImageResizer和图像文件
我在我们的web应用程序中一直使用得很好,但现在我需要它来调整大小,并为没有(也不能)文件扩展名的图像提供服务,例如:Asp.net mvc 不带扩展名的ImageResizer和图像文件,asp.net-mvc,imageresizer,Asp.net Mvc,Imageresizer,我在我们的web应用程序中一直使用得很好,但现在我需要它来调整大小,并为没有(也不能)文件扩展名的图像提供服务,例如: http://localhost:58306/ClientImages/Batch/2012/12/10/f45198b7c452466684a4079de8d5f85f?width=600 在这种情况下,我知道我的文件总是TIFF的,但它们不会有文件扩展名 我有什么选择 /resizer.debug.ashx: 更新 我遵照计算机语言学家的指示: protected
http://localhost:58306/ClientImages/Batch/2012/12/10/f45198b7c452466684a4079de8d5f85f?width=600
在这种情况下,我知道我的文件总是TIFF的,但它们不会有文件扩展名
我有什么选择
/resizer.debug.ashx:
更新
我遵照计算机语言学家的指示:
protected void Application_Start()
{
Config.Current.Pipeline.PostAuthorizeRequestStart +=
delegate
{
var path = Config.Current.Pipeline.PreRewritePath;
var clientImgsRelPath = PathUtils.ResolveAppRelative("~/ClientImages/");
var isClientImageRequest = path.StartsWith(clientImgsRelPath, StringComparison.OrdinalIgnoreCase);
if (isClientImageRequest)
Config.Current.Pipeline.SkipFileTypeCheck = true;
};
// other app start code here
}
http://localhost:58306/ClientImages/Batch/2012/12/10/92d67b45584144beb5f791aaaf760252?width=600
只响应原始图像,不调整大小
这里也有人问:
这是在使用Cassini或Visual Studio web服务器或您想称之为的任何东西进行开发时发生的。首先,您必须使用IIS7集成模式。经典模式不起作用;它不允许ASP.NET访问无扩展请求 除非您明确告知,否则ImageResizer无法知道无扩展URL是图像 本文件说明: 本质上,您将在URL上执行逻辑(通常是String.StartsWith),以确定ImageResizer是否应将文件视为图像
Config.Current.Pipeline.PostAuthorizeRequestStart += delegate(IHttpModule sender, HttpContext context) {
string path = Config.Current.Pipeline.PreRewritePath;
//Skip the file extension check for everything in this folder:
if (path.StartsWith(PathUtils.ResolveAppRelative("~/folder/of/images"),
StringComparison.OrdinalIgnoreCase)){
Config.Current.Pipeline.SkipFileTypeCheck = true;
}
};
您应该在global.asax中的应用程序启动中注册此事件处理程序。您是否尝试指定
&process=always
以强制将处理作为映像?