我见过几个具有动态下载链接的网站。
他们要求提供有效的电子邮件地址,并将动态创建的下载链接发送到该地址。 前任。 www.mysite.domain/hashvalue1
但是,由于该文件存在于域中的特定位置,他们是如何做到这一点的呢? www.mysite.domain/downloads
有相关指南吗?
最佳答案
他们使用“UrlRewrite”和 ASP.NET HttpHandler。
网址重写:http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
处理程序:Downlaod.ashx
using System;
using System.Web;
public class GetDownload : IHttpHandler
{
private static string file = "your file location";
public void ProcessRequest (HttpContext context)
{
if(UsersHasRights(context))
{
context.Response.TransmitFile(file);
}
}
public bool IsReusable
{
get { return false; }
}
}
关于asp.net - 动态下载链接算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1485974/