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.Net中写了一个附件上传和下载的程序,附件上传到数据库中,然后将附件的GUID保存起来,我们可以根据GUID来找到数据库中的附件,一般附件下载的代码是:
private void Download(string ID)
{
file = logic.GetA ......
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 ......
· 第一:
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToString( ) );
}
第二:
private void Button2_Click( object sender, System.EventArgs e ......