DownloadHandler.ashx
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<%@ WebHandler Language="C#" Class="DownloadHandler" %>
//===============================================================================================
//
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.
//
//===============================================================================================
using System;
using System.Web;
using System.IO;
using MyWebPagesStarterKit;
/// <summary>
/// This handler serves files from the "~/App_Data/_Downloads/" folder (which is by default not accessible over the web).
/// </summary>
public class DownloadHandler : IHttpHandler
{
#region IHttpHandler Members
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
try
{
//get the sectionId
string section = context.Request.QueryString["section"];
//get the filename
string file = context.Request.QueryString["file"];
//build the path
string path = context.Server.MapPath(string.Format("~/App_Data/_Downloads/{0}/{1}", section, file));
// get the pageId for the authentication
string pageId = context.Request.QueryString["pg"];
//user authentication:
WebPage _page = new WebPage(pageId);
if (_page.AllowAnonymousAccess == false && context.User.Identity.IsAuthenticated == false)
throw new Exception("User is not allowed to view this file");
if (File.Exists(path))
{
context.Response.Clear();
context.Response.AddHeader("Pragma", "public");
context.Response.AddHeader("Expires", "0");
context.Response.AddHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
context.Response.AddHeader("Content-Type", "application/force-download");
context.Response.AddHeader("Content-Type", "application/octet-stream");
context.Response.AddHeader("Content-Type", "application/download");
context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", file));
context.Response.AddHeader("Content-Transfer-Encoding", "binary");
context.Response.AddHeader("Content-Length", new FileInfo(path).Length.ToString());
后面还有 11 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
