杂记
一般处理程序获取session值
1.要在一般处理程序中获取其他页面的session值,需要引用名空间:
using System.Web.SessionState;
2.然后继承一个接口:IRequiresSessionState,如图:
3.然后就可以获得session值了:
HttpContext context = new HttpContext();
string s =context.Session["Verifycode"].ToString();
怎么用SQL语句添加新字段并设置默认值
ALTER TABLE 表名 ADD sex BIT NOT NULL DEFAULT 1
因为数据库正在使用,所以无法获得对数据库的独占访问权---还原或删除数据库的解决方法
还原或删除sql server 2008数据库时,经常烩出现:
“因为数据库正在使用,所以无法获得对数据库的独占访问权”,终解决方案如下
关键SQL语句:
ALTER DATABASE [datebase] SET OFFLINE WITH ROLLBACK IMMEDIATE
用完之后再
ALTER database [ datebase] set online
轻松实现asp.net中遍历cookies,session,application,小总结
- //遍历cookies
- for (int i = 0; i < HttpContext.Current.Request.Cookies.Count; i++)
- {
- Response.Write(HttpContext.Current.Request.Cookies.Keys[i] + ":" +HttpContext.Current.Request.Cookies[i].Value.ToString()+ "<br>");
- }
- //遍历session
- for (int i = 0; i < HttpContext.Current.Session.Count; i++)
- {
- Response.Write(HttpContext.Current.Session.Keys[i] + ":" + HttpContext.Current.Session[i].ToString() + "<br>");
- }
- //遍历application
- for (int i = 0; i < HttpContext.Current.Application.Count; i++)
- {
- Response.Write(HttpContext.Current.Application.Keys[i] + ":" + HttpContext.Current.Application[i].ToString() + "<br>");
- }