Asp.net源码专业站
首页->新知实践->UrlReWrite(Url重写或伪静态)完美示例源码>>UrlRewriter/URLRewriter.Form.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:UrlReWrite(Url重写或伪静态)完美示例源码
当前文件:文件类型 UrlReWriter/UrlRewriter/URLRewriter.Form.cs[2K,2009-6-12 11:57:50]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Web; 5using System.Web.Security; 6using System.Web.UI; 7using System.Web.UI.WebControls; 8using System.Web.UI.WebControls.WebParts; 9using System.Web.UI.HtmlControls; 10 11/// <summary> 12/// FormRewriter 的摘要说明 13/// </summary> 14namespace URLRewriter.Form 15{ 16 public class FormRewriterControlAdapter : System.Web.UI.Adapters.ControlAdapter 17 { 18 public FormRewriterControlAdapter() 19 { 20 } 21 22 protected override void Render(HtmlTextWriter writer) 23 { 24 base.Render(new RewriteFormHtmlTextWriter(writer)); 25 } 26 } 27 28 public class RewriteFormHtmlTextWriter : HtmlTextWriter 29 { 30 public RewriteFormHtmlTextWriter(HtmlTextWriter writer) 31 : base(writer) 32 { 33 base.InnerWriter = writer.InnerWriter; 34 } 35 public RewriteFormHtmlTextWriter(System.IO.TextWriter writer) 36 : base(writer) 37 { 38 base.InnerWriter = writer; 39 } 40 41 public override void WriteAttribute(string name, string value, bool fEncode) 42 { 43 //If the attribute we are writing is the "action" attribute, and we are not on a sub-control, 44 //then replace the value to write with the raw URL of the request - which ensures that we'll 45 //preserve the PathInfo value on postback scenarios 46 if (name == "action") 47 { 48 HttpContext context = HttpContext.Current; 49 if (context.Items["ActionAlreadyWritten"] == null) 50 { 51 //We will use the Request.RawUrl property within ASP.NET to retrieve the origional 52 //URL before it was re-written. 53 value = context.Request.RawUrl; 54 //Indicate that we've already rewritten the <form>'s action attribute to prevent 55 //us from rewriting a sub-control under the <form> control 56 context.Items["ActionAlreadyWritten"] = true; 57 } 58 } 59 base.WriteAttribute(name, value, fEncode); 60 } 61 } 62 63}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:UrlReWrite(Url重写或伪静态)完美示例源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146