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

Asp.net 中 Cookie的使用方法

方法1:
比如建立一个名为cnlive,值为"123"的cookie
HttpCookie cookie = new HttpCookie["cnlive"];
cookie.Value = "123";
Response.AppendCookie(cookie);
取刚才写入的Cookie值:
HttpCookie cookie = Request.Cookies["cnlive"];
cookieValue = cookie.Value;
在一个Cookie中储存多个信息:
HttpCookie cookie = new HttpCookie("cnlive");
cookie.Values.Add("weburl",http://www.cnlive.net);
cookie.Values.Add("author","honfei");
cookie.Values.Add("sitename","网友与媒体");
Response.AppendCookie(cookie);
读取:
HttpCookie cookie = Request.Cookies["cnlive"];
value1 = cookies.Values["weburl"];
value2 = cookies.Values["author"];
.............
方法二:
Response.Cookies["UserID"].Value = "123";//将用户ID写入Cookie
Response.Cookies["UserID"].Expires = DateTime.Now.AddDays(1);
读取方法:
Request.Cookies["UserID"].Value;
写cookie
HttpCookie cookie = new HttpCookie("Info");//定义cookie对象以及名为Info的项
DateTime dt = DateTime.Now;//定义时间对象
TimeSpan ts=new TimeSpan(1,0,0,0);//cookie有效作用时间,具体查msdn
cookie.EXPires = dt.Add(ts);//添加作用时间
cookie.Values.Add("user","cxbkkk");//增加属性
cookie.Values.Add("userid","1203");
Response.AppendCookie(cookie);//确定写入cookie中 读取cookie
if(Request.Cookies["Info"]!=null)
{
string temp=Convert.ToString(Request.Cookies["Info"].Values["user"])+" "+Convert.ToString(Request.Cookies["Info"].Values["userid"]);
//读全部就用Request.Cookies["Info"].Value)
if(temp=="")
{
Response.Write("空");
}
else
Response.Write(temp);
}
else
{
Response.Write("error");
} 修改cookie
Response.Cookies["Info"]["user"] = "2";
Response.Cookies["Info"].Expires = DateTime.Now.AddDays(1);
// 删除cookie下的属性
HttpCookie acookie=Request.Cookies["Info"];
acookie.Values.Remove("userid");
acookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(acookie); 删除所有cookie,就是设置过期时间为现在就行了
int limit=Request.Cookies.Count - 1;
for(int i=0;i<limit;i++)
{
acookie = Request.Cookies(i)
acookie.Expires = DateTime.N


相关文档:

欢迎您学习 asp.net 2.0

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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">
< ......

关于ASP.NET控件在编译时找不到的解决方案

     本人开发ASP.NET已有两年多了。谈起ASP.NET真是让我欢喜让我忧。昨天又出现了那个奇怪的问题,就是在页面完全写好后,重新生成时报:XXX(页面名)不包含(XXX)的定义。在CS文件下是可以用 this.xxx 写出来的,页面上也没问题。在解决方案中重新生成页又可以,重新生成网站就会报这个错误。将this.XXX ......

ASP.NET的HTMLTable原样导出到Excel

 
文章出处:http://www.cnblogs.com/tomcat112906/articles/922639.html
 
ASP.NET的HTMLTable原样导出到Excel
js代码 : function PrintTableToExcelEx(objTab)
            {
        &nbs ......

asp.net生成静态页(之二)

先建个html模版页(template.htm):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
 
<title>$title</title>
 
& ......

asp.net中“线程正被中止”异常的解决方法

asp.net中“线程正被中止”异常的解决方法
在项目里负责异常处理部分:异常信息的写入,读取,查看,因此就可以看到各种异常,受益匪浅
看到有N多的“线程正被中止”异常,而且来自同一个页面。
System.Threading.ThreadAbortException: 线程正被中止。
at System.Threading.Thread.AbortInternal( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号