随笔分类 - Asp.Net
摘要:///<summary>///根据当前页码和总页数显示分页链接///</summary>///<paramname="page"></param>///<paramname="total"></param>voidShowLink(intpage,inttotal,intbookid,intchapterid,CWmlwml){//显示当前页的前后多少页constintcount=3;//显示上一页if(page>1){wml.Href("detail.aspx?bo
阅读全文
摘要:///<summary>///根据模板和一个DataTable得到一个解析字符串///</summary>///<paramname="template">字符串模板</param>///<paramname="dt">一个DataTable</param>///<returns>返回一个解析模板后的字符串</returns>publicstaticstringRender(stringtemplate,DataTabledt){if(dt==null||dt
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using System.Web;using System.Threading;/// <summary>/// 用于生成商品详细页的类/// </summary>public class ProductHtmlCreate{ /// <summary> /// 存储商品静态文件的文件夹路径,在Application_Start事件中被设置为磁盘的绝对路径 ///
阅读全文
摘要:static void Main(string[] args) { HttpWebResponse web = MySpider.GetResponse("http://localhost:1853/WebForm1.aspx"); DecompressGZip(web ); Console.ReadLine(); }public static MemoryStream DecompressGZip(HttpWebResponse res) { //如果服务器使用了Transfer-Encoding:chunked缓冲输出,则只要服务器端Flush了,就会触发此方法,而不是等到服务器发送过
阅读全文
摘要:在www.a.com下放SetCookie.ashx,内容如下:/// summary /// $codebehindclassname$ 的摘要说明 /// /summary [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class SetCookie : IHttpHandler { public void ProcessRequest(HttpContext context) { context
阅读全文
摘要:传统方法如下:protected override void Render(HtmlTextWriter writer){string content = string.Empty; StringWriter stringWriter = new StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); try { // 将当前页面的内容呈现到临时的 HtmlTextWriter 对象中 base.Render(htmlWriter); htmlWriter.Close(); // 得到当前页面
阅读全文
摘要:在global.assx中重写如下方法:public override string GetVaryByCustomString(HttpContext context, string arg) { if (arg == "news_ascx") { string value= HttpRuntime.Cache["news_ascx"]; if (value == null) { value = DateTime.Now.ToString(); HttpRuntime.Cache.Insert("", value, null, DateTime.MaxValue, new TimeSp
阅读全文
摘要:在配置web.config之前调用在VS2008命令行工具中运行 aspnet_regsql ,将对应的表安装到指定数据库。在web.config里对Profile进行如下配置 connectionStrings add name="myConn" connectionString="server=.;integrated security=true;database=AB;"/ /connectionStringsprofile inherits="MyClasses.MyPro" defaultProvider="MyProfileProvider" enabled="tru
阅读全文
摘要:/// summary /// 根据模板,使用此法分析的方法输出字符串 /// /summary /// param name="template"/param /// param name="dt"/param /// returns/returns public static string Render(string template, DataTable dt) { StringBuilder sb = new StringBuilder(1000); Liststring arr = new Liststring(); Liststring
阅读全文
摘要:public class MyCache{ /// summary /// 插入一个缓存 /// /summary /// param name="name"缓存键/param /// param name="value"缓存值/param /// param name="isAbsoulute"是否使用绝对过期,是则为true否则为false/param /// param name="isOverride"如果缓存存在,是否覆盖缓存值/param /// param name="absoluteDate"绝对过期时间/param /// p
阅读全文
摘要:其实就是把AllowScriptAccess="sameDomain"改为AllowScriptAccess="always"如下(6、12行,都必要) 1object2classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"3codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"4width="550"height="400"align="middle"5paramname="movie"value="http:
阅读全文
摘要:今天用SubSonic生成数据访问层代码,一直报“从索引 0 处开始,初始化字符串的格式不符合规范”的错误,仔细检查发现跟引用的SubSonic.dll和App.Config里的链接字符串没有任何关系,最后删除App.Config,再新建App.Config,问题解决。为什么?我也不知道。
阅读全文
摘要:1.window.escape()与HttpUtility.UrlEncodeUnicode()编码格式一样:将一个汉字编码为%uxxxx格式不会被window.escape编码的字符有:@ _ - . * / + 这与http://www.w3school.com.cn/js/jsref_escape.asp上的解释不符合2.window.encodeURIComponent()与HttpUtility.UrlEncode()编码格式一样:将一个汉字编码为%xx%xx%xx的格式不会被window.encodeURIComponent编码的字符有:' ( ) * - . _ ! ~
阅读全文
摘要:今天在aspx在拖自定义控件时,出现这个错误。Google以后,发现自定义的控件类的访问修饰符是public,那么为什么还出现这个错误?寻找后发现,原来使用Register注册自定义控件的时候,没有设置Assembly的值,设置Assembly以后恢复正常。
阅读全文
摘要:在网上寻找许久,发现很多都是无效的,难道只能用%@ OutputCache %来设置页面缓存?最后终于在 Asp.Net 3.5解密一书中找到我想要的在页面的Page_Load事件里添加如下代码: protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetExpires(DateTime.Now.AddSeconds(15)); //Response.Cache.SetMaxAge(Time
阅读全文
浙公网安备 33010602011771号