泊客天涯 2016-01-11 14:22 采纳率: 0%
浏览 1352

求助:asp.net转成asp代码

大家谁能帮我把下面代码转成asp代码<%%>这样的

 <%@ WebHandler Language="C#" Class="upload" %>

using System;
using System.Web;

public class upload : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        HttpRequest request = context.Request;

        int c = request.Files.Count;

        //接收上传的数据并保存到服务器
        for (int i = 0; i < c; i++)
        {
            HttpPostedFile file = request.Files[i];

            string fileName = request["fileName"];
            if (string.IsNullOrEmpty(fileName)) fileName = System.IO.Path.GetFileName(file.FileName);

            string path = context.Server.MapPath("~/upload/" + fileName);
            file.SaveAs(path);
        }


        string type = request["type"];
        string user = request["user"];
        string name = request["name"];

        //此处返回的JSON字符串为手动拼接,未处理字符串转义等特殊情况,仅作演示
        string json = "\"time\":\"" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "\"";
        if (type != null) json += ",\"type\":\"" + type + "\"";
        if (user != null) json += ",\"user\":\"" + user + "\"";
        if (name != null) json += ",\"name\":\"" + name + "\"";

        Finish("{" + json + "}");
    }

    /// <summary>
    /// 完成上传
    /// </summary>
    /// <param name="json">回调函数参数</param>
    private void Finish(string json)
    {
        HttpResponse Response = HttpContext.Current.Response;

        Response.Write(json);
        Response.End();
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}
  • 写回答

2条回答 默认 最新

  • threenewbee 2016-01-11 14:30
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题