Upload.Service/UploadHandler.ashx.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;

namespace Upload.Service
{
    /// <summary>
    /// UploadHandler 的摘要说明
    /// </summary>
    public class UploadHandler : IHttpHandler
    {
        private readonly JavaScriptSerializer js;

        private string StorageRoot
        {
            get { return Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Files/")); } //Path should! always end with '/'

            //get { return Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/")); }
        }

        public UploadHandler()
        {
            js = new JavaScriptSerializer();
            js.MaxJsonLength = 41943040;
        }

        public bool IsReusable { get { return false; } }


        //        string result = file.FileName;
        //2              context.Response.Headers.Add("Cache-Control", "no-cache");
        //3              context.Response.AddHeader("Access-Control-Allow-Origin", "*");
        //4              context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with");
        //5              context.Response.AddHeader("Location", callUrl + "?msg=" + result);
        //6              context.Response.Redirect(callUrl + "?msg=" + result); 

        public void ProcessRequest(HttpContext context)
        {
            //HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
            //HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT");
            context.Response.AddHeader("Pragma", "no-cache");
            context.Response.AddHeader("Cache-Control", "private, no-cache");
            //context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with");


            HandleMethod(context);

            //string result = "xofly.rar";
            //string callUrl = "http://localhost:61397/myTest.html";
            //context.Response.AddHeader("Location", callUrl + "?msg=" + result);
            //context.Response.Redirect(callUrl + "?msg=" + result); 
        }

        // Handle request based on method
        private void HandleMethod(HttpContext context)
        {
            switch (context.Request.HttpMethod)
            {
后面还有 160 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。