参考了论坛里几位大师的意见,在项目中添加了ashx文件,代码如下:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string Filepath = context.Server.MapPath(context.Request.FilePath);
if (context.Request.UrlReferrer.Host.Contains("cmltl.cn"))
{
context.Response.ContentType = context.Request.ContentType;
context.Response.WriteFile(Filepath);
}
}
public bool IsReusable
{
get
{
return false;
}
}