΢Èí¹Ù·½ ASP.NET URL ÖØд
ʵÏÖ URL ÖØд
¿ÉÒÔʹÓà ISAPI ɸѡÆ÷ÔÚ IIS Web ·þÎñÆ÷¼¶±ðʵÏÖ URL ÖØд£¬Ò²¿ÉÒÔʹÓà HTTP Ä£¿é»ò HTTP ´¦Àí³ÌÐòÔÚ ASP.NET ¼¶±ðʵÏÖ URL ÖØд¡£±¾ÎÄÖصã½éÉÜÈçºÎʹÓà ASP.NET ʵÏÖ URL ÖØд£¬Òò´ËÎÒÃǽ«²»¶ÔʹÓà ISAPI ɸѡÆ÷ʵÏÖ URL ÖØдµÄϸ½Ú½øÐÐÉîÈë̽ÌÖ¡£µ«ÊÇ£¬ÓдóÁ¿µÄµÚÈý·½ ISAPI ɸѡÆ÷¿ÉÓÃÓÚ URL ÖØд£¬ÀýÈ磺
ISAPI Rewrite
IIS Rewrite
PageXChanger
»¹ÓÐÐí¶àÆäËûµÄɸѡÆ÷£¡
ͨ¹ý System.Web.HttpContext ÀàµÄ RewritePath() ·½·¨£¬¿ÉÒÔÔÚ ASP.NET ¼¶±ðʵÏÖ URL ÖØд¡£HttpContext Àà°üº¬ÓйØÌض¨ HTTP ÇëÇóµÄ HTTP Ìض¨ÐÅÏ¢¡£¶ÔÓÚ ASP.NET ÒýÇæÊÕµ½µÄÿ¸öÇëÇ󣬾ùΪ¸ÃÇëÇó´´½¨Ò»¸ö HttpContext ʵÀý¡£´ËÀà¾ßÓÐÈçÏÂÊôÐÔ£ºRequest ºÍ Response£¬Ìṩ¶Ô´«ÈëÇëÇóºÍ´«³öÏìÓ¦µÄ·ÃÎÊ£»Application ºÍ Session£¬Ìṩ¶ÔÓ¦ÓóÌÐòºÍ»á»°±äÁ¿µÄ·ÃÎÊ£»User£¬ÌṩÓйØͨ¹ýÁËÉí·ÝÑéÖ¤µÄÓû§µÄÐÅÏ¢£»ÆäËûÏà¹ØÊôÐÔ¡£
ʹÓà Microsoft® .NET Framework Version 1.0£¬RewritePath() ·½·¨¿ÉÒÔ½ÓÊܵ¥¸ö×Ö·û´®×÷ΪҪʹÓõÄз¾¶¡£HttpContext ÀàµÄ RewritePath(string) ·½·¨ÔÚÄÚ²¿¶Ô Request ¶ÔÏóµÄ Path ÊôÐÔºÍ QueryString ÊôÐÔ½øÐиüС£³ýÁË RewritePath(string)£¬.NET Framework 1.1 »¹°üÀ¨ÁíÒ»ÖÖÐÎʽµÄ RewritePath() ·½·¨£¬´Ë·½·¨¿ÉÒÔ½ÓÊÜÈý¸ö×Ö·û´®ÊäÈë²ÎÊý¡£´Ë±¸ÓÃÖØÔØÐÎʽ²»½öÒªÉèÖà Request ¶ÔÏóµÄ Path ÊôÐÔºÍ QueryString ÊôÐÔ£¬»¹ÒªÉèÖÃÄÚ²¿³ÉÔ±±äÁ¿£¬ÕâЩ±äÁ¿ÓÃÓÚ¼ÆËã Request ¶ÔÏóµÄ PhysicalPath¡¢PathInfo ºÍ FilePath ÊôÐÔÖµ¡£
ÒªÔÚ ASP.NET ÖÐʵÏÖ URL ÖØд£¬ÐèÒª´´½¨ HTTP Ä£¿é»ò HTTP ´¦Àí³ÌÐò£¬ÒÔ±ãÍê³ÉÒÔϲÙ×÷£º
¼ì²é±»ÇëÇóµÄ·¾¶£¬ÒÔÈ·¶¨ URL ÊÇ·ñÐèÒªÖØд¡£
Èç¹ûÐèÒªÖØд£¬Í¨¹ýµ÷Óà RewritePath() ·½·¨À´ÖØд·¾¶¡£
ÀýÈ磬¼ÙÉèÎÒÃǵÄÍøÕ¾Öаüº¬Ã¿¸öÔ±¹¤Í¨¹ý /info/employee.aspx?empID=employeeID ¾ù¿É·ÃÎʵÄÐÅÏ¢¡£ÎªÁËʹ URL ¿ÉÒÔ¸ü¶àµØ±»“ɾ½Ú”£¬ÎÒÃÇ¿ÉÒÔ¾ö¶¨Í¨¹ýÒÔϵØÖ·À´·ÃÎÊÔ±¹¤Ò³Ã棺/people/EmployeeName.aspx¡£Õâ¾ÍÊÇÎÒÃÇҪʹÓà URL ÖØдµÄÒ»¸öÀý×Ó¡£Ò²¾ÍÊÇ˵£¬ÔÚÇëÇó /people/ScottMitchell.aspx Ò³Ãæʱ£¬ÎÒÃÇÒªÖØд¸Ã URL£¬ÒÔ±ãʹÓà /info/employee.aspx?empID=1001 Ò³Ãæ¡£
ʹÓà HTTP Ä£¿éÖ´ÐÐ URL ÖØд
ÔÚ ASP.NET ¼¶±ðÖ´ÐÐ URL ÖØдʱ£¬¿ÉÒÔʹÓà HTTP Ä£¿é»ò HTTP ´¦Àí³ÌÐòÀ´Ö´ÐÐÖØд¡£Ê¹Óà HTTP Ä£¿éʱ£¬±ØÐë¾ö¶¨ÔÚÇëÇóÓÐЧÆÚÄÚµÄÄĸöʱ¼äµãÉÏÀ´¼ì²é URL ÊÇ·ñÐèÒªÖØд¡£Õ
Ïà¹ØÎĵµ£º
ÔÚÓÃVS2008µ÷ÊÔÍøÕ¾µÄʱºò£¬Í»È»Ò³Ãæ²»ÄÜÕý³£ÏÔʾÁË£¬IEÏÔʾ“ÎÞ·¨ÏÔʾ¸ÃÍøÒ³”¡£
Ö¢×´Ò»£º
¡¡¡¡IEµØÖ·À¸ÀïÃæÏÔʾµÄ¶Ë¿ÚºÅºÍ×ÀÃæÈÎÎñÀ¸ÓÒϽǓASP.NET Development Server”µÄ¶Ë¿Ú²»Ò»Ö£¬¶ø°ÑIEµØÖ·À¸µÄ¶Ë¿ÚºÅ¸Ä³É“ASP.NET Development Server”ÏÔʾµÄ¶Ë¿ÚºÅ£¬½á¹ûÍøÒ³¾ÍÄܳöÀ´¡£
½â¾ö ......
ViewResult:Ò»°ã³ÊÏÖij¸öaspxÎļþ£¬ÓÉView·½·¨·µ»Ø¡£
RedirectToResult:ʹä¯ÀÀÆ÷Öض¨Ïò£¬ÓÉRedirect·½·¨·µ»Ø¡£
RedirectToRouteResult:Ö±½Ó½»¸øÏÂÒ»¸öAction£¬ÓÉRedirectToAction·½·¨·µ»Ø¡£ ......
·ÖÒ³´æ´¢¹ý³ÌÈçÏ´úÂëPages.sql£º
CREATE PROCEDURE Pages
@tblName varchar(255), -- ±íÃû
@strGetFields varchar(1000) = '*', -- ÐèÒª·µ»ØµÄÁÐ
@fldName varchar(255)='', -- ÅÅÐòµÄ×Ö¶ÎÃû
@pageSize int = 10, -- Ò³³ß´ç
@pageIndex int = 1, -- Ò³Âë
@doCount ......
AutoPostBackÄÄÈ¥ÁË?
´ÓǰʹÓÃweb
Form¿ª·¢µÄ³ÌÐòÔ±¾³£»áÎʵ½AutoPostBackÅÜÄÄÈ¥ÁË£¿Ê¹ÓÃIDE£¬²¢ÇÒÔÚAutoPostBack´ò¸ö¹´ÊǷdz£ÈÝÒ׵ġ£¶øÕýÊÇÒòΪÈÝÒ×ʹ
Óã¬ËùÒÔ´ó¶à¿ª·¢ÈËÔ±²»»áÈ¥ÏëAutoPostBackÊÇÔõÑùµÄ»úÖÆ¡£Êµ¼ÊÉÏ£¬Èç¹ûÄãÑ¡ÔñAutoPostBack£¬ÔòDropDownList»á±»Ìí¼Ó
Ò»¸öÒý·¢javascriptʼþµÄonchangeÊôÐÔ£¬µ¼ÖÂD ......
web.config
<customErrors mode="On" defaultRedirect="ApplicationErroy.aspx" >
<error statusCode="403" redirect="403.htm"/>
<error statusCode="404" redirect="404.htm"/>
<error statusCode= ......