日期:2014-05-17  浏览次数:20405 次

asp.net。初学编程。求如何ashx获取Session或者Cookies中的用户名
asp.net。初学编程 ,求如何通过读取Session或者Cookies中的用户名
然后下面这个imageUp.ashx接收
主要是imageUp.ashx如何获得Cookies的用户名?然后pathbase = 用户名+"/" ;
<%@ WebHandler Language="C#" Class="imageUp" %>
<%@ Assembly Src="Uploader.cs" %>

using System;
using System.Web;
using System.IO;
using System.Collections;

public class imageUp : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        //上传配置
        int size = 2;           //文件大小限制,单位MB                             //文件大小限制,单位MB
        string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };         //文件允许格式


        //上传图片
        Hashtable info = new Hashtable();
        Uploader up = new Uploader();
        
        string pathbase = null;
        int path=Convert.ToInt32( up.getOtherInfo(context, "dir"));
        if (path == 1)
        {
            pathbase = "upload/" ;                  
            
        }else{
            pathbase = "upload1/";
        }
        
        info = up.upFile(context, pathbase, filetype, size);                   //获取上传状态
        
        string title = up.getOtherInfo(context, "pictitle");                   //获取图片描述