只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态。还请确保在应用程序配置的

1.先写一个类继承IHttphander和System.Web.SessionState.IRequiresSessionState

 

using System;
using System.Collections.Generic;
using System.Web;

namespace DtCms.Web
{
    public class Hander1:IHttpHandler,System.Web.SessionState.IRequiresSessionState
    {
        public Hander1()
        {
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Server.Transfer("WF1.aspx");
            // WF1 f = new WF1();
            string path = context.Request.Url.AbsolutePath;
            // string sr = context.Request.Url.AbsoluteUri;
            //context.Response.Write(f.Page.Controls.ToString());

            // context.Response.Redirect("WF1.aspx");
            string uri = path.Substring(0, path.LastIndexOf('/'));
            string pageName = path.Substring(path.LastIndexOf('/') + 1);
            string realPName = pageName.Substring(0, pageName.LastIndexOf('.')) + ".aspx";
            string realPath = uri +"/"+ realPName;
            context.Server.Transfer(realPath);
        }
        public bool IsReusable
        {
            get { return false; }
        }
    }
}

2.
     
   

 

你可能感兴趣的:(只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态。还请确保在应用程序配置的)