日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

asp.net2.0 URL重寫以及urlMappings問題(1)_.Net教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:談談HtmlControl與WebControl的區(qū)別與用途
Web控件和Html控件雖然好多功能相同并且長得很像 但是它們的內部實現(xiàn)機制是完全不一樣的 Web控件要比Html控件執(zhí)行效率要好 1. 使用起來也相當方便,舉個簡單的例子,例如Button

在asp.net2.0中的urlMappings倒是非常好用,可惜暫不支持正則表達式,不過,好在如果用IHttpModule的話
不管什么樣的請求都會先經(jīng)過IHttpModule這樣就為URL重寫提供了一個好機會:

下面是我寫的一個IHttpModule:

using System;
using System.Web;

public class ReWriteModule : IHttpModule
{
public ReWriteModule()
{
}
public override string ToString()
{
return this.GetType().ToString();
}

void IHttpModule.Dispose()
{
}
private static System.Xml.XmlDocument ruleDoc = null;
private static System.Xml.XmlDocument GetRuleConfig(System.Web.HttpContext app)
{
if (ruleDoc == null)
{
ruleDoc = new System.Xml.XmlDocument();
ruleDoc.Load(app.Server.MapPath("~/rule.xml"));
}
return ruleDoc;
}
public static string GetUrl(System.Web.HttpContext cxt, string path)
{
System.Xml.XmlDocument doc = GetRuleConfig(cxt);
System.Xml.XmlNodeList lst = doc.GetElementsByTagName("RewriterRule");
string pat = "";
foreach (System.Xml.XmlNode nd in lst)
{
System.Xml.XmlNodeList sub = nd.ChildNodes[0].ChildNodes;
foreach (System.Xml.XmlNode chk in sub)
{
pat = "^" chk.InnerText "$";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(pat, System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
if (reg.IsMatch(path))
{
return reg.Replace(path, nd.ChildNodes[1].InnerText);
}
}
}
return null;
}

分享:ASP.NET 2.0服務器控件之客戶端功能
  多數(shù)在表示層應用的服務器控件主要由兩個部分組成:服務器端功能和客戶端功能。服務器端功能永遠是服務器控件的核心,而隨著技術的發(fā)展,客戶端功能也逐漸變得越來越重要。只有兩個部分

共2頁上一頁12下一頁
來源:模板無憂//所屬分類:.Net教程/更新時間:2008-08-22
相關.Net教程