ASP.NET Web.configÅäÖÃÏê½â
Ò»¡¢ÈÏʶWeb.configÎļþ
Web.config ÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ý.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈ쵀 Web.configÎļþ£¬°üÀ¨Ä¬ÈϵÄÅäÖÃÉèÖã¬ËùÓеÄ×ÓĿ¼¶¼¼Ì³ÐËüµÄÅäÖÃÉèÖá£Èç¹ûÄãÏëÐÞ¸Ä×ÓĿ¼µÄÅäÖÃÉèÖã¬Äã¿ÉÒÔÔÚ¸Ã×ÓĿ¼ÏÂн¨Ò»¸ö Web.configÎļþ¡£Ëü¿ÉÒÔÌṩ³ý´Ó¸¸Ä¿Â¼¼Ì³ÐµÄÅäÖÃÐÅÏ¢ÒÔÍâµÄÅäÖÃÐÅÏ¢£¬Ò²¿ÉÒÔÖØд»òÐ޸ĸ¸Ä¿Â¼Öж¨ÒåµÄÉèÖá£
(Ò»).Web.ConfigÊÇÒÔXMLÎļþ¹æ·¶´æ´¢,ÅäÖÃÎļþ·ÖΪÒÔϸñʽ
1.ÅäÖýڴ¦Àí³ÌÐòÉùÃ÷
Ìص㣺 λÓÚÅäÖÃÎļþµÄ¶¥²¿£¬°üº¬ÔÚ <configSections> ±êÖ¾ÖС£
2.Ìض¨Ó¦ÓóÌÐòÅäÖÃ
Ìصã: λÓÚ <appSetting> ÖС£ ¿ÉÒÔ¶¨ÒåÓ¦ÓóÌÐòµÄÈ«¾Ö³£Á¿ÉèÖõÈÐÅÏ¢.
3.ÅäÖýÚÉèÖÃ
Ìصã: λÓÚ <system.Web> ½ÚÖУ¬¿ØÖÆAsp.netÔËÐÐʱµÄÐÐΪ.
4.ÅäÖýÚ×é
Ìصã: Óà <sectionGroup> ±ê¼Ç£¬¿ÉÒÔ×Ô¶¨Òå·Ö×飬¿ÉÒԷŵ½ <configSections> ÄÚ²¿»òÆäËü <sectionGroup> ±ê¼ÇµÄÄÚ²¿.
(¶þ).ÅäÖýڵÄÿһ½Ú
1. <configuration> ½Ú
¸ùÔªËØ£¬ÆäËü½Ú¶¼ÊÇÔÚËüµÄÄÚ²¿.
2. <appSetting> ½Ú
´Ë½ÚÓÃÓÚ¶¨ÒåÓ¦ÓóÌÐòÉèÖÃÏî¡£¶ÔһЩ²»È·¶¨ÉèÖ㬻¹¿ÉÒÔÈÃÓû§¸ù¾Ý×Ô¼ºÊµ¼ÊÇé¿ö×Ô¼ºÉèÖÃ
Ó÷¨:
I.
<appSettings>
<add key= "Conntction " value= "server=192.168.85.66;userid=sa;password=;database=Info; "/>
<appSettings>
¶¨ÒåÁËÒ»¸öÁ¬½Ó×Ö·û´®³£Á¿£¬²¢ÇÒÔÚʵ¼ÊÓ¦ÓÃʱ¿ÉÒÔÐÞ¸ÄÁ¬½Ó×Ö·û´®£¬²»ÓÃÐ޸ijÌʽ´úÂë.
II. <appSettings>
<add key= "ErrPage " value= "Error.aspx "/>
<appSettings>
¶¨ÒåÁËÒ»¸ö´íÎóÖض¨ÏòÒ³Ãæ.
3. <compilation> ½Ú
¸ñʽ:
<compilation
defaultLanguage= "c# "
debug= "true "
/>
I.default language: ¶¨Òåºǫ́´úÂëÓïÑÔ,¿ÉÒÔÑ¡ÔñC#ºÍVB.netÁ½ÖÖÓïÑÔ.
IIdebug : Ϊtrueʱ£¬Æô¶¯aspxµ÷ÊÔ£» Ϊfalse²»Æô¶¯aspxµ÷ÊÔ£¬Òò¶ø¿ÉÒÔÌá¸ßÓ¦ÓóÌÐòÔËÐÐ
ʱµÄÐÔÄÜ¡£ Ò»°ã³ÌÐòÔ±ÔÚ¿ª·¢Ê±ÉèÖÃΪtrue,½»¸ø¿Í»§Ê±ÉèÖÃΪfalse.
4. <customErrors> ½Ú
¸ñʽ:
<customErrors
mode= "RemoteOnly "
defaultRedirect= "error.aspx "
<error statusCode= "440 " redirect=
Ïà¹ØÎĵµ£º
Äú¿ÉÒÔͨ¹ýÒÔÏÂÉèÖÿØÖÆasp.net¶Ô·þÎñÆ÷ÄÚ´æµÄÕ¼Óᣲ¢ÄÜÉèÖÃaspnet½ø³Ì¶¨Ê±Öؽ¨£¨ÀàËÆIIS6ÖÐAppPoolÀïµÄ¶¨Ê±ÖØÆô£©£¬ÕâÑù¿ÉÒÔ±ÜÃâ·þÎñÆ÷³¤Ê±¼äÔËÐÐaspnetÕ¼ÓôóÁ¿¿ÕÏÐÄڴ棬ÓÐÀûÓÚÌá¸ßaspnetÔËÐÐЧÂÊ¡£
aspnetÅäÖÃÎļþλÖÃΪ
CWINDOWSMicrosoft.NETFrameworkv1.1.4322CONFIGmachine.config
ÓÃÎı¾±à¼Æ÷´ò¿ª¸ÃÎļþ£¬ÕÒµ ......
ASP.NET¿ÉÒÔÀûÓÃWebConfigurationManagerºÍÖ±½ÓÀûÓÃXML·½Ê½²Ù×÷web.config,WebConfigurationManager±È½Ï¼òµ¥£¬µ«ÊÇÇå³ý×¢ÊÍ´úÂë¡£Á½Õß²Ù×÷·½Ê½¶¼ÐèÒªÓÐдȨÏÞ¡£
·½·¨Ò»£¬ÀûÓÃWebConfigurationManager£¬ÐèÒªÒýÓÃSystem.Web.Configuration.WebConfigurationM ......
ASP.NET±à³ÌÄ£ÐÍÖ®ASP.NETÒ³ÃæÉúÃüÖÜÆÚͼ½â
ASP.NET±à³ÌÄ£ÐÍÖÐASP.NETÒ³ÃæÉúÃüÖÜÆÚÊÇָʲôÄØ£¿Ëü°üÀ¨Ê²Ã´ÄØ£¿ASP.NET±à³ÌÄ£ÐÍÖ®ASP.NETÒ³ÃæÉúÃüÖÜÆÚ¾ßÌåµÄ¹ý³ÌÓÐÄÄЩÄØ£¿ÏÂÃæ¾Í¿ªÊ¼ÎÒÃǵĽ²½â°É£º
ASP.NET Ò³ÔËÐÐʱ£¬´ËÒ³½«¾ÀúÒ»¸öÉúÃüÖÜÆÚ£¬ÔÚÉúÃüÖÜÆÚÖн«Ö´ÐÐһϵÁд¦Àí²½Öè¡£ÕâЩ²½Öè°üÀ¨³õʼ»¯¡¢ÊµÀý»¯¿Ø¼þ¡¢»¹ÔºÍ ......
¿´µ½ºÜ¶àÅóÓÑÎÊÕâ¸öÎÊÌâ,ËäÈ»ºÜ¼òµ¥,µ«ÊǺܳ£ÓÃ,ÄóöÀ´ÌÖÂÛÏ°ɡ£¡£¡£¸ßÊÖÆ®¹ý£¡
¼ÇµÃ¼¸Äêǰż¸Õѧ.NETµÄʱºòżÊÇÕâÑù¸ÉµÄ
+Õ¹¿ª-C#
<%@ Control Language="c#" %>
//html...
<script runat="server">
public string BackClo ="red"; //ÕâÀﶨÒåÁËÒ»¸ö²ÎÊý
public void Page_Load()
{ }
</sc ......