复制代码 代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
</connectionStrings>
<appSettings>
</appSettings>
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Home/LogOn" defaultUrl="http://www.vevb.com/" timeout="600" slidingExpiration="true" path="http://www.vevb.com/" enableCrossAppRedirects="true"></forms>
</authentication> <httpCookies domain=".xxx.com"/>
<machineKey validationKey="AAA977D304FB289C182E00C710A099C9F92986DC25AD69F8" decryptionKey="AAA2B3F76A9359431E717CA8275EE72EEEDC70ED55152010" validation="SHA1"/>
</system.web>
<!--此节点只需加到文件站下--> <system.webServer>
<handlers>
<add path="*.*" verb="*" type="Web.Handler.Download" />
</handlers>
</system.webServer>
</configuration>
复制代码 代码如下:
namespace Web.Handler
{
/// <summary>
/// 文件下载登陆验证
/// </summary>
public class Download : IHttpHandler
{
public bool IsReusable
{
get
{
return true;
}
}
public void ProcessRequest(HttpContext context)
{
if (context.User.Identity.IsAuthenticated)
{
string fileName = context.Server.MapPath(context.Request.FilePath);
context.Response.ContentType = Path.GetExtension(fileName);
context.Response.TransmitFile(context.Request.FilePath);
}
else
{
context.Response.Write("您未登录!");
}
}
}
}
新闻热点
疑难解答
图片精选