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

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

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

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

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

下面是我寫的一個(gè)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服務(wù)器控件之客戶端功能
  多數(shù)在表示層應(yīng)用的服務(wù)器控件主要由兩個(gè)部分組成:服務(wù)器端功能和客戶端功能。服務(wù)器端功能永遠(yuǎn)是服務(wù)器控件的核心,而隨著技術(shù)的發(fā)展,客戶端功能也逐漸變得越來(lái)越重要。只有兩個(gè)部分

共2頁(yè)上一頁(yè)12下一頁(yè)
來(lái)源:模板無(wú)憂//所屬分類:.Net教程/更新時(shí)間:2008-08-22
相關(guān).Net教程