ASP.net´íÎó´¦Àí(´íÎóÌøתҳ webconfig)
ASP.net´íÎó´¦Àí(´íÎóÌøתҳ webconfig)
ʹÓö¨ÖÆ´íÎóÒ³Ãæ
ËäÈ»ÎÒÃÇ·¢Ë͸øÓû§µÄ¹«ÓôíÎóÐÅÏ¢ÊÇ°²È«µÄ£¬¾ÍÊÇ˵Ëü²»»áÍþвµ½Ó¦ÓóÌÐòµÄÃØÃÜ£¬µ«ÊÇÕâÑùµÄÐÅÏ¢²¢²»ºÃ¿´¡£Ò²ÐíÄãÏ£ÍûÓû§ÓÀÔ¶Ò²¿´²»µ½ÕâÑùµÄÐÅÏ¢¡£Ïà·´£¬µ±´¦ÀíÇëÇóµÄ¹ý³ÌÖУ¬Èç¹û·¢ÉúÁËÒ»¸öΪ´¦ÀíµÄ´íÎó£¬ÄãÏ£ÍûÄܹ»ÏÔʾ×Ô¼ºµÄ“¶¨ÖÆ´íÎóÒ³Ã攣¬ÏÔʾ³ö×Ô¼ºµÄÆ·ÅÆÒÔ¼°Ìض¨µÄ´íÎóÐÅÏ¢¡£
ÏòASP.NET Ó¦ÓóÌÐòÖÐÔö¼Ó¶¨ÖÆ´íÎóÐÅÏ¢·Ç³£ÈÝÒס£Ê×ÏÈ£¬±àд×Ô¼ºµÄ webÒ³Ã棬Ëü¿ÉÒÔÊÇÈκÎÀàÐ͵ÄÎļþ£º.htm£¬.aspx£¬.asp£¬µÈµÈ¡£È»ºóÔÚÓ¦ÓóÌÐòµÄconfig.webÎļþÖÐÐÞ¸ÄÅäÖÃÐÅÏ¢£¬ÈÃËüÖ¸ÏòÕâ¸öÎļþ¡£
¾ÙÀý˵Ã÷£¬ÒÔÏÂÕâ¸öÅäÖÃÐÅϢ˵Ã÷ÔÚ·¢ÉúÁËÈκÎδÄÜÔ¤¶¨´¦Àí´íÎóµÄÇé¿öÏ£¬ä¯ÀÀÆ÷¶¼Ó¦¸Ã±»Öض¨Ïòµ½“ErrorPage.aspx”Ò³Ã棺
<configuration>
<customerrors mode="remoteonly" defaultredirect="ErrorPage.aspx" />
</configuration>
<customerrors>±ê¼ÇÖеēdefaultredirect”ÊôÐÔ¶¨ÒåÁËÔÚ·¢Éú´íÎóµÄÇé¿öÏ£¬Óû§½«±»Öض¨Ïòµ½µÄ“ĬÈϔҳÃæ¡£»òÕߣ¬Ò²¿ÉÒÔ¸ù¾ÝÏìÓ¦µÄhttp´úÂë״̬£¬Öض¨Ïòµ½ÆäËüµÄÒ³ÃæÀ´¸²¸ÇÕâ¸öĬÈÏÖµ¡£ÀýÈ磺Öض¨Ïòµ½Ò»¸öÌØÊâµÄ“δÕÒµ½Îļþ”´íÎóÒ³Ãæ¡¢“·Ç·¨·ÃÎÊ”´íÎóÒ³Ãæ¡¢“·þÎñÆ÷³åÍ»”´íÎóÒ³ÃæµÈµÈ¡£
¾ÙÀý˵Ã÷£¬ÒÔϵÄÅäÖÃÐÅÏ¢¸²¸Ç3¸öÌض¨µÄhttp ״̬´úÂ룬ËùÓÐÆäËü´íÎ󶼷µ»Øµ½Ò»¸öĬÈÏÒ³Ã棺
<customerrors defaultredirect="http://anotherhost/error.aspx" mode="remoteonly">
<error statuscode="500" redirect="http:/anotherhost/pages/callsupport.html" />
<error statuscode="404" redirect="http:/anotherhost/pages/adminmessage.html" />
<error statuscode="403" redirect="http:/anotherhost/pages/noaccess.html" />
</customerrors>
ÔÚ¶¨ÖÆ´íÎóÒ³ÃæÉÏÓÐÒ»¼þÊÂÎÒÃÇÒѾÓöµ½¹ý£¬ÄǾÍÊÇËäÈ»ËüÃǶÔÓÚÒѾÍê³ÉµÄÇé¿ö·Ç³£ÓÐÓã¬È»¶øÔÚ¿ª·¢¹ý³ÌÖÐÈ´·Ç³£ÄÑÒÔ¶Ô¸¶¡£ÒòΪÄãÔ¤Ïëµ½ÔÚ¿ª·¢¹ý³ÌÖлáÓÐbug£¬²¢ÇÒµ±Äã·¢ÏÖµÄʱºò£¬ÕæµÄÏ£Íû¿´µ½Êµ¼ÊµÄ´íÎóÐÅÏ¢¸ú×Ù¡£ÎªÁ˽â¾öÕâ¸öÎÊÌ⣬<customerrors>±ê¼ÇÖ§³ÖÒ»¸öÓÐ3¸öÖµµÄ“mode”ÊôÐÔ£º
“on”£ºÒâ˼ÊÇ×ÜÊÇ·¢³ö¶¨ÖÆ´íÎóÒ³Ã棻
“off”£ºÒâ˼ÊÇ´Ó²»·¢³ö¶¨ÖÆ´íÎóÒ³Ã棨Äã×ÜÊÇ¿´µ½ÔʼµÄ´íÎóÐÅÏ¢
Ïà¹ØÎĵµ£º
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<!--
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0 ......
һ˵µ½ÐÂÎÅϵͳµÄ»°£¬Ò»¶¨»á̸µ½¾²Ì¬Ò³ÃæÉú³ÉµÄ£¬ÒòΪ¾²Ì¬Ò³Ãæ²»µ«ÊǶÁÈ¡Ëٶȿ죬¶øÇÒÓÖ°²È«£»
¾²Ì¬Ò³ÃæµÄÉú³É²»¹ÜÊÇСµ½ÏÖÔÚµÄÆóÒµÍøÕ¾´óÖÁÍøÒ×£¬£Ñ£ÑµÈÃÅ»§¶¼Óõ½ÁË£»
ÄÇôÎÒÃÇÈçºÎÀ´Éú³É¾²Ì¬Ò³ÄØ£¿
ÒÔʲô·½Ê½Éú³É¾²Ì¬Ò³ÃæÄØ……
ÔÚÉú³É¾²Ì¬Ò³ÃæµÄʱºòÓÐÄÇЩÊÇҪעÒâµÄÄØ£º
¾²Ì¬Ò³ÃæÃüÃû
ͳһ´æ·ÅĿ¼ ......
public static Boolean WriteTextFile(string content, string filepath,string name)
{
FileStream fs;
StreamWriter sw;
if (!System.IO.Directory.Exists(filepath))
{
DirectoryInfo DirInfo = Directory.CreateDirectory(filepath); //´´½¨Ä¿Â¼
DirI ......
WebRequest mywebrq;
WebResponse mywebresp;
StreamReader sr;
Streamwriter sw;
Private void Page_Load(object sender,EventArgs e) { mywebreq=WebRequest.Create( http://localhost/Test.aspx ); mywebresp=mywebreq.GetResponse();
sr=new streamReader(mywebresp.GetResponsestream());
strHtml=sr.ReadT ......
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯¡¡
¡¡¡¡Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
¡¡¡¡·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø± ......