ASP.NET(C#)ÖÐ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="err440page.aspx"/>
<error statusCode="500" redirect="err500Page.aspx"/>
/>
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
asp.netÖдò¿ªÐ´°¿ÚµÄ¶àÖÖ·½·¨(תÔØ)
1.Response.Redirect("XXX.aspx",true)——Ö±½ÓתÏòеÄÒ³Ã棬Դ°¿Ú±»´úÌæ;
2. Response.Write("<script>window.open(XXX.aspx','_blank')</script>")——Ô´°¿Ú±£Áô£¬ÁíÍâÐÂÔöÒ»¸öÐÂÒ³Ãæ;
3.Response.Write("<script>window.location=XXX. ......
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.comboBox2.Items.Clear();
switch(this.comboBox1.SelectedIndex)
  ......
1. µÄ.net£¬ÓÃÊó±êÓÒ»÷ÄãµÄ¹¤³Ì(½â¾ö·½°¸)£¬Ñ¡Ôñadd new project(Ìí¼Óн¨ÏîÄ¿)¡£
2.Ñ¡Ôñsetup and deployment projects£¨°²×°ºÍ²¿ÊðÏîÄ¿£©µÄ web setup project(web°²×°ÏîÄ¿)¡££¨×¢ÒâsetupprojectµÄ´æ·Å·¾¶¡£Í¨³£Ä¬ÈÏ£©
3.vsµÄ´°¿Ú»áÏÔʾÎļþϵͳ£¨you setup name£©¡£ÓÃÊó±êµã»÷×óÀ¸ÏµÄ"web application folder" µÄ¼Óº ......
1.Asp.NetÖм¸ÖÖÏàËƵıê¼Ç·ûºÅ: < %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Container.DataItem("tit") %>
< %= %>: ÔÚ³ÌÐòÖ´ÐÐʱ±»µ÷Ó㬿ÉÒÔÏÔʾºǫ́±äÁ¿Öµ
Èç:
*.aspxÖУº < %= ......