易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net中cookie的处理

原文:刘武|asp.net中cookie的处理  
使用中发现用Request.Cookies.Remove()无法删除cookie,google了一下发现一般是通过将过期时间设置成过去的时间来完成删除的。顺便整理下cookie的操作:
一 创建
1 单值的创建
C#-Code:
HttpCookie hc = new HttpCookie("Value");
hc.Value = "value";
Response.AppendCookie(hc);
2 多值的创建
C#-Code:
HttpCookie hc = new HttpCookie("Value");
hc["Value1"] = "value1";
hc["Value2"] = "value2;
Response.AppendCookie(hc);
二 读取
1 单值的读取
C#-Code:
string value = Request.Cookies["Value"].Value;
2 多值的读取
C#-Code:
string value1 = Request.Cookies["Value"]["Value1"].ToString();
string value2 = Request.Cookies["Value"]["Value2"].ToString();
三 删除
C#-Code:
HttpCookie hc = Request.Cookies["Value"];
hc.Expires = DateTime.Now.AddDays(-1);
//下面这句一定要加上,否则无法删除
Response.AppendCookie(hc);


相关文档:

ASP.NET 2.0 中的SqlCacheDependency特性


   
   它还会在指定的数据库中增加几个存储过程,用来让ASP.NET引擎查询追踪的数据表的情况。
   
   然后,它会给我们要追踪的Table加上几个Trigger,分别对应到Insert、Update、Delete操作,这几个Trigger的语句非常简单,就是把“AspNet_SqlCacheTablesF ......

在ASP.NET中下载文件

//TransmitFile实现下载
    protected void Button1_Click(object sender, EventArgs e)
    {
        /*
        微软为Response对象提供了一个新的方法TransmitFile来解决使用Response.BinaryWrite
&nbs ......

asp.net 继承身份验证

 在ASP.NET网站中网站管理后台需要经常验证用户身份,要实现这种功能就可以利用那个继承机制和ASP.NET的事件机制.首先定义一个需要进行身份验证的BasePage类,继承自Page类,在BasePage类的构造函数中定义它的加载事件的处理代码,这样所有继承自BasePage类的页面都能自动执行身份验证.
/// <summary>
/// 验证 ......

数字分页导航条 (asp.net C#)


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using ......

jQuery Ajax 方法调用 Asp.Net WebService 的详细例子

  jQuery Ajax 调用Aspx.Net WebService 的几个常用可以直接复制代码运行。

  ws.aspx 代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runa ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号