asp.net UrlÖØдѧϰ
1.ͨ¹ýRewritePathʵÏÖÖØд
URLÖØд¿ÉÒÔͨ¹ý±à³ÌµÄ·½Ê½À´ÊµÏÖ¡£ASP.NETÖеÄContex.RewritePath()·½·¨¿ÉÒÔÈÃÄã´Ó³ÌÐòÖÐʵÏÖÖØдÇëÇóµÄURL¡£Ò»µ©ÖØдºó£¬ÏµÍ³½«Ê¹ÓÃеķ¾¶À´¼ÌÐøÖ´ÐÐÕâ¸öÇëÇó¡£
ÔÚGlobal.asaxÎļþµÄApplication_BeginRequest()·½·¨ÖУ¬ÄãÐèÒªÔö¼Ó´úÂëÀ´ÔĶÁ½øÀ´µÄ·¾¶£¬È»ºó¸ù¾ÝÒ»¸ö»ò¶à¸öURLÖØд¹æÔòÀ´³ÉÐèÒª½øÒ»²½´¦ÀíµÄ·¾¶¡£ÏÂÃæµÄÀý×ÓÖ´ÐÐÒÔÏÂURLÖØд¹æÔò£º
ÊäÈëµÄurl:"/URLRewriting/OldUrl.aspx Õæʵ·ÃÎʵÄurl:"/URLRewriting/NewUrl.aspx"
ÊäÈëµÄurl:"/URLRewriting/UserAccount/{UserId}.aspx Õæʵ·ÃÎʵÄurl:"/URLRewriting/UserAccount.aspx?id={UserID}
ʹÓÃContex.RewritePath()ʵÏÖURLÖØд:
void Application_BeginRequest(object sender, EventArgs e)
{
string path=Request.Url.ToString();
if(Regex.IsMatch(path,"WebTest/(.+).aspx",RegexOptions.IgnoreCase))
{
String idString = path.Substring(path.LastIndexOf('/') + 1, path.Length - path.LastIndexOf('/') - 6);
Context.RewritePath("Default.aspx?id=" + idString);
}
else if(Regex.IsMatch(path, "/URLRewriting/OldUrl.aspx",RegexOptions.IgnoreCase))
{
Context.RewritePath("/URLRewriting/NewUrl.aspx");
}
}
ÔÚÕâ¸öÀý×ÓÖУ¬Ã¿´ÎÒ»¸öеÄÇëÇó±»´¦ÀíµÄʱºò£¬Ëü½«Ê×ÏȲ鿴Õâ¸öApplication_BeginRequest()¡£Í¨¹ýʹÓÃRequest.UrlÊôÐÔÀ´»ñµÃÊäÈëµÄURL·¾¶£¬È»ºóͨ¹ýÕýÔò±í´ïʽÀ´Ó¦ÓÃÍøÕ¾URLÖØд¹æÔò£¬Æ¥Åäµ½ÆÚÍûµÄÊäÈëÍøÖ·ºó£¬½«ËüÃÇÖØд³ÉÄãÏ£ÍûתÏòµÄÍøÖ·¡£
µ±ÖØд¹æÔò±È½Ï¼òµ¥ÇÒ¹æÄ£±È½ÏСµÄʱºò£¬Ê¹ÓÃContext.RewritePath() ·½·¨ÒÔ±à³ÌµÄ·½Ê½ÖØдURLЧ¹û±È½Ï²»´í£¬µ«ÊÇһЩ´óÐÍÍøվͨ³£Óзdz£¶àµÄURLÖØд¹æÔò¡£ÊÖ¹¤·½Ê½¶ÔËùÓÐÕâЩÖØд¹æÔò½øÐбà³Ì¿ÉÄÜÊÇÒ»¼þÂé·³ÇÒÈÝÒ׳ö´íµÄ·½·¨¡£
Ò»¸ö¸üºÃµÄ½â¾ö·½·¨ÊÇ´Óweb.configÎļþÖÐʹÓÃÒ»¸öHttpModule(httpÄ£¿é)À´¶¯Ì¬µÄ´¦ÀíURLÖØд¹æÔò¡£¸üÁîÈ˸ßÐ˵ÄÊÇ£¬ÄãÎÞÐè×Ô¼º¶¯ÊÖÀ´±àдHttpModuleÀ´´¦ÀíÕâЩÈÎÎñ£¬ÒѾÓм¸¸ö·Ç³£²»´íµÄÃâ·Ñ°æ¹©ÄãʹÓá£ÒÔÏÂÊÇÆäÖм¸¸ö£ºURLRewriting.Net £¬URLRewriter.Net £¬Rewrite.Net ¡£
2.ʹÓÃURLRewriting.NetÖØдUrl(
Ïà¹ØÎĵµ£º
ÓÃVS¿ª·¢ASP.NETÍøÕ¾³ÌÐòµÄʱºò,»á½«Àà»òWeb Services·ÅÔÚÌØÊâµÄÎļþ¼ÐÖÐ,·²ÊÇ·ÅÔÚÕâЩÌØÊâµÄÎļþ¼ÐÖÐ(App_Themes³ýÍâ)µÄ³ÌÐò»òÄÚÈÝÖ»ÔÊÐíÓ¦ÓóÌÐò·ÃÎÊ,¶ÔÓÚÍøÒ³µÄRequestÔò²»ÓèÏìÓ¦(ÎÞ·¨¶ÁÈ¡).
Îļþ¼Ð &nbs ......
£¨×ª ÔÎĵØÖ·http://blog.sina.com.cn/s/blog_524c848901009e7b.html~type=v5_one&label=rela_nextarticle ×÷Õß
ÀîÑóµÄ²©¿Í
http://blog.sina.com.cn/liiyang£©
66.Èí¼þ¿ª·¢¹ý³ÌÒ»°ãÓм¸¸ö½×¶Î£¿Ã¿¸ö½×¶ÎµÄ×÷Óã¿
´ð£ºÐèÇó·ÖÎö£¬¼Ü¹¹Éè¼Æ£¬´úÂë±àд£¬QA£¬²¿Êð
67.ÔÚc#ÖÐusingºÍnewÕâÁ½¸ö¹Ø¼ü×ÖÓÐʲôÒâÒ壬 ......
ÕâÀïÊÇÎÒµÄÒ»¸ö¼òµ¥µÄjquery+jsonµÄÁ¬¿â²Ù×÷£¬Ö»ÊÇÒ»¸ö¼òµ¥²éѯ£¬
//ºǫ́´úÂë
<%@ WebHandler Language="C#" Class="show" %>
using System;
using System.Web;
using System.Collections.Generic;
using Model;
using DAL;
using System.Web.Script.Serialization;
public class show ......
ϵͳ¼òµ¥½éÉÜ£º
ºÜ±ê×¼µÄÅäÖãºasp.net 2.0+SqlServer 2000 or 2005,һЩͳ¼Æͼ²ÉÓõÄÊÇflash¼¼Êõ~¸Õ±ÏÒµµÄʱºòÔÚÒ»¼Òµç×ÓÕþÎñ¹«Ë¾¹¤×÷ʱ¿ª·¢µÄ£¬ÕâÌ×ϵͳǿ¾ÍÇ¿ÔÚËü²»ÊÇÓ¦ÓÃϵͳ£¬¶øÊÇÒ»¸ö¹¤¾ß£¬¿ÉÒÔÔڴ˹¤¾ß»ù´¡ÉÏ£¬¾¹ý¶þ´Î¿ª·¢£¬ÑÜÉú³öÂú×ãÕþ¸®²¿ÃÅÐÅÏ¢»¯ÐèÇóµÄÓ¦ÓÃϵͳ£¡£¡
Õ ......
ÔÚÃæÊÔµÄʱºò£¬¾³£»áÓöµ½ÕâÑùµÄÎÊÌ⣬ÆäʵÎÒÃÇ»á¶ÔÆäÖеļ¸ÖÖ·½·¨±È½ÏÊìϤ£¬ÒòΪÏîÄ¿Öо³£Ê¹Óᣵ«ÊÇҪȫÃæµÄ»Ø´ðASP.NETÖÐÒ³Ãæ´«ÖµµÄ·½Ê½£¬¹À¼ÆÍùÍùºÜÄÑÈ«Ãæ¡£
Ò».
ʹÓÃQueryString±äÁ¿
¡¡¡¡¡¡¡¡QueryStringÊÇÒ»Öַdz£¼òµ¥Ò²ÊÇʹÓñȽ϶àµÄÒ»ÖÖ´«Öµ·½Ê½£¬µ«ÊÇËü½«´«µÝµÄÖµÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖÐ,Èç¹ûÊÇ´«µÝÒ»¸ö»ò ......