ASP.NET½Ì³Ì:URLÖØдµÄʵÏÖ
×î½üÓиöÅóÓÑÒª×öurlÖØдµÄ¶«Î÷,ÎÒ°ïËûŪÁËŪ,»ØÍ·¿´µ±Äê×Ô¼ºÐ´µÄÄǸöÎÄÕÂ,µ±Ê±ÒÔΪ×Ô¼ºÐ´µÄºÜÈÝÒ×Àí½â.µ«ÏÖÔÚÔÙ¿´È´¾õµÃдµÄ²»ºÃ.¶ø½ñÌì°Ù¶ÈÁËÒ»ÏÂurlrewriter·¢ÏÖÎÒÕâ¸öÎÄÕ¾¹È»Åŵڶþ.ΪÁË·½±ã¸ü¶àÅóÓÑ,ÎÒÔÙдµã¶«Î÷²¹³äÏÂ.
Ò»°ãÓðٶÈËѵÄÅóÓѶ¼ÊǶÔÕâ¸ö²»Á˽⵫ÓÖ¼±ÐèÒªÓõÄ,ÎÒÏë,ÔÙ¶àµÄÓïÑÔÒ²±È²»¹ýÒ»¾ä´úÂë.ÓÚÊÇÎҰѽñÌì°ïÅóÓÑʱºòдµÄÒ»¸öСÀý×Ó´«ÁËÉÏÀ´.Õâ¸öСÀý×ÓµÄÄ¿µÄÊÇʵÏÖ¶ÔÈÎÒâurlµÄÖØд(µ«²»°üÀ¨¶þ¼¶ÓòÃûµÄ,ÓÐÐèÒª¶þ¼¶ÓòÃûµÄÒ²¿ÉÒÔÏÈÁ˽âÏÂurlÖØдµÄ¸ÅÄî). Õâ¸öСÏîÄ¿µÄÖÆ×÷¹ý³ÌÈçÏÂ
ÐèÒª¶ÔÖîÈçhttp://song2.cn/viewnews/2009/3/2.htmlµÄurl½øÐÐÖØд.½«ÆäÖØдΪhttp://song2.cn/viewnews.aspx?id=2&year=2009&month=3
ÏÂÔØ΢ÈíµÄÄǸöURLRewriter.dll,ʹÓÃÕâ¸ö¶Ôurl½øÐÐÖØд.
ÎÒÃÇÀ´¿´Õâ¸öurl, http://song2.cn/viewnews/2009/3/2.html(µ±È»Ò²¿ÉÄÜÊÇ3.html,6.html,7.html).ÒªÖØд,Ê×ÏÈÊǽػñurlÇëÇó,È»ºó·ÖÎöµ±Ê±µÄurl,×îºóÌøתµ½ÏàÓ¦µÄÒ³Ãæ.ËùÒÔÎÒÃǵÚÒ»²½ÊÇÒª½Ø»ñurlÇëÇó.Ϊ´Ëн¨Ò»¸öÀà¿â½ÐURL,ÔÚ¸ÃÀà¿âÖÐÒýÓÃURLRewriter.dll.н¨Ò»¸öÀàmyrewritter.cs,´úÂëÈçÏÂ
namespace URL
{
public class myrewritter : URLRewriter.BaseModuleRewriter
{
protected override void Rewrite(string requestedPath, HttpApplication app)
{
if (requestedPath.Contains("viewnews/2009/3/2.html"))
app.Context.RewritePath("/viewnews.aspx?id=2&year=2009&month=3");
else
app.Context.RewritePath("/here.aspx");
}
}
}
¿ÉÒÔ¿´µ½¸ÃÀà¼Ì³ÐÁËURLRewriter.BaseModuleRewriter,È»ºóÔÚRewrite·½·¨ÖмÓÈëÁËÎÒÃÇ×Ô¼ºµÄÂß¼.ÏÖÔÚ,Ö»Òªµ±Ç°µÄurlÇëÇóÊÇviewnews/2009/3/2.html,ÎÒÃǾͻὫҳÃæÖØдµ½/viewnews.aspx?id=2&year=2009&month=3.
ÕâÖ»ÊÇÒ»¸ö¼òµ¥µÄÀý×Ó,
Ïà¹ØÎĵµ£º
protected void Button6_Click(object sender, EventArgs e)
{
this.Label11.Text = HtmlEncode(this.TextBox3.Text);
}
protected static string HtmlEn ......
1¡¢Í¨¹ý¸½¼ÓÒ»¸öcookiecontainerµ½httprequest¶ÔÏóÖУ¬¿ÉÒԵõ½µÇ¼ºó·µ»ØµÄ´ú±íSESSION IDµÄCOOKIE¡£
2¡¢½«´ËCOOKIE°üº¬ÔÚÒ»¸öcookiecontainerÖв¢¸½¼Óµ½ÁíÒ»¸öHTTPREQUESTÇëÇóÖУ¬Ôò¿ÉÒÔʵÏÖSESSIONµÄ»¹Ô¡£
²¿·ÖÖ÷Òª´úÂ룺
CookieContainer cookieContainer =& ......
Ò»¡¢
Js
ÉèÖÃĬÈÏ°´Å¥
function
document.onkeydown()
{
var
e=event
.srcElement;
&nbs ......
µ÷ÓÃ
ÑéÖ¤Â룺<input type="text" id="txtValidate" style="border: solid 1px #9B9B9B; width: 85px;
height: 17px;" /> <img src="Rnd.aspx" mce_src="Rnd.aspx" style="width: 58px; height: 17px;
border: solid 1px #9B9B9B" align="abs ......
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn;
SqlCommand cmd1, cmd2;
SqlTransaction tra;
conn = new SqlConnection("server=.;database=test;uid=sa;pwd=123");
conn.Open();
tra = conn.BeginTransaction();//¿ªÊ¼ÊÂÎ ......