问候!
@H_502_2@我创建了一个APSX Web表单,它根据一些提供的参数返回一个远程图像.它可以像这样使用:
<img src="/ImageGetter.aspx?param1=abc¶m2=123" />@H_502_2@ImageGetter.aspx的标记和代码看起来类似于:
<%@ OutputCache Duration="100000" VaryByParam="*" Location="ServerAndClient" %> <%@ Page Language="C#" AutoEventWireup="false" EnableSessionState="False" CodeBehind="ImageGetter.aspx.cs" Inherits="ACME.Helpers.ImageGetter" %>@H_502_2@此代码在ImageGetter.aspx的Page_Load方法中调用:
byte[] data = null; Dictionary<string,string> file_locations = GetImageLocations(param1,param2); try { data = new WebClient().DownloadData(file_locations["main"]); } catch (WebException wex) { try { data = new WebClient().DownloadData(file_locations["backup"]); } catch (Exception e) { throw; } } Response.ContentType = "image/jpeg"; Response.OutputStream.Write(data,data.Length); Response.End();@H_502_2@从我的测试来看,它似乎不是缓存.这可能与输出缓存有关,还是应该根据查询字符串参数编写自己的缓存来存储字节数组?