您的位置:首页 > 产品设计 > UI/UE

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

2011-11-22 12:03 1136 查看
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.<system.web><httpHandlers>

<add verb="*" path="*.html" type="DtCms.Web.Hander1"/>

</httpHandlers></system.web>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐