ASP.NET学习经验收集(不断更新)
在日常学习和使用ASP.NET的过程中,有些比较特殊有用的经验收集在这里,方便自己记忆和理解,也希望能帮助到一些初学者参考。如果有些不足的地方希望高手不吝赐教!!!
一、在一般处理文件(ashx)中使用Session时,需要引进命名空间:using System.Web.SessionState; 并且使该类实现IRequiresSessionState接口,然后就能通过HttpContext.Current.Session使用Session了!
简易代码如下:
using System.Web.SessionState;
........
public class Handler : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
HttpContext.Current.Session["user"] = "luoyisheng";
}
public bool IsReusable
{
get
{
return false;
}
}
}
相关文档:
asp.net(C#)实现SQL2000数据库备份和还原
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.Htm ......
在ASP.NET2.0中,为我们提供了两种新功能,方便我们制作共同特征一致的页面和导航。这两种功能是母板页和网站导航。对于母板页大家很清楚了,不过在做母板页时,经常需要添加导航栏,对于此asp.net 2.0 使我们的工作大为简化。这便是站点地图的使用。
顾名思义,站点地图就是在站点 ......
System.Drawing.Image watermark = System.Drawing.Image.fromFile(Server.MapPath("watermark.gif"));
Bitmap srcImg = new Bitmap(Server.MapPath("example.jpg"));
Graphics graphics = Graphics.fromImage(srcImg);
graphics.DrawImage(watermark,
srcImg.Width - watermark.Width,
srcImg.Height - w ......
asp.net中导出有很多方法。其中比较推荐的兼容导出是导出为word/excel兼容的mhtml格式并设置流格式为word或excel。
这中方法的好处是可以建立一个通用的库。本文中提出了一个通用的导出类,实践中使用效果较好。(ps,html解析类写的比较仓促,各位如有兴趣可重写一下~)
///
///@Author Simsure
///@Version 1.0
///
......