ÈÏʶASP.NETÅäÖÃÎļþWeb.config
Ò»¡¢ÈÏʶWeb.configÎļþ
¡¡¡¡Web.configÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ýVB.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈϵÄ
Web.configÎļþ£¬°üÀ¨Ä¬ÈϵÄÅäÖÃÉèÖã¬ËùÓеÄ×ÓĿ¼¶¼¼Ì³ÐËüµÄÅäÖÃÉèÖá£Èç¹ûÄãÏëÐÞ¸Ä×ÓĿ¼µÄÅäÖÃÉèÖã¬Äã¿ÉÒÔÔÚ¸Ã×ÓĿ¼ÏÂн¨Ò»¸öWeb.configÎļþ¡£Ëü¿ÉÒÔÌṩ³ý´Ó¸¸Ä¿Â¼¼Ì³ÐµÄÅäÖÃÐÅÏ¢ÒÔÍâµÄÅäÖÃÐÅÏ¢£¬Ò²¿ÉÒÔÖØд»òÐ޸ĸ¸Ä¿Â¼Öж¨ÒåµÄÉèÖá£
¡¡¡¡ÔÚÔËÐÐʱ¶ÔWeb.configÎļþµÄÐ޸IJ»ÐèÒªÖØÆô·þÎñ¾Í¿ÉÒÔÉúЧ£¨×¢£º<processModel> ½ÚÀýÍ⣩¡£µ±È»Web.configÎļþÊÇ¿ÉÒÔÀ©Õ¹µÄ¡£Äã¿ÉÒÔ×Ô¶¨ÒåÐÂÅäÖòÎÊý²¢±àдÅäÖýڴ¦Àí³ÌÐòÒÔ¶ÔËüÃǽøÐд¦Àí¡£
¡¡¡¡¶þ¡¢web.configÅäÖÃÎļþ£¨Ä¬ÈϵÄÅäÖÃÉèÖã©ÒÔÏÂËùÓеĴúÂ붼Ӧ¸ÃλÓÚ
<configuration>
<system.web>
¡¡¡¡ºÍ
</system.web>
</configuration>
¡¡¡¡Ö®¼ä£¬³öÓÚѧϰµÄÄ¿µÄÏÂÃæµÄʾÀý¶¼Ê¡ÂÔÁËÕâ¶ÎXML±ê¼Ç
¡¡¡¡1¡¢<authentication> ½Ú
¡¡¡¡×÷ÓãºÅäÖà ASP.NET Éí·ÝÑéÖ¤Ö§³Ö£¨ÎªWindows¡¢Forms¡¢PassPort¡¢NoneËÄÖÖ£©¡£¸ÃÔªËØÖ»ÄÜÔÚ¼ÆËã»ú¡¢Õ¾µã»òÓ¦ÓóÌÐò¼¶±ðÉùÃ÷¡£<authentication> ÔªËرØÐèÓë<authorization> ½ÚÅäºÏʹÓá£
¡¡¡¡Ê¾Àý£º
¡¡¡¡ÒÔÏÂʾÀýΪ»ùÓÚ´°Ì壨Forms£©µÄÉí·ÝÑéÖ¤ÅäÖÃÕ¾µã£¬µ±Ã»ÓеǽµÄÓû§·ÃÎÊÐèÒªÉí·ÝÑéÖ¤µÄÍøÒ³£¬ÍøÒ³×Ô¶¯Ìøתµ½µÇ½ÍøÒ³¡£
<authentication mode="Forms" >
<forms loginUrl="logon.aspx" name=".FormsAuthCookie"/>
</authentication>
¡¡¡¡ÆäÖÐÔªËØloginUrl±íʾµÇ½ÍøÒ³µÄÃû³Æ£¬name±íʾCookieÃû³Æ
¡¡¡¡2¡¢<authorization> ½Ú
¡¡¡¡×÷Ó㺿ØÖÆ¶Ô URL ×ÊÔ´µÄ¿Í»§¶Ë·ÃÎÊ£¨ÈçÔÊÐíÄäÃûÓû§·ÃÎÊ£©¡£´ËÔªËØ¿ÉÒÔÔÚÈκμ¶±ð£¨¼ÆËã»ú¡¢Õ¾µã¡¢Ó¦ÓóÌÐò¡¢×ÓĿ¼»òÒ³£©ÉÏÉùÃ÷¡£±ØÐèÓë<authentication> ½ÚÅäºÏʹÓá£
¡¡¡¡Ê¾Àý£ºÒÔÏÂʾÀý½ûÖ¹ÄäÃûÓû§µÄ·ÃÎÊ
<authorization>
¡¡<deny users="?"/>
</authorization>
¡¡¡¡×¢£ºÄã¿ÉÒÔʹÓÃuser.identity.nameÀ´»ñÈ¡ÒѾ¹ýÑéÖ¤µÄµ±Ç°µÄÓû§Ãû£»¿ÉÒÔʹÓÃ
web.Security.FormsAuthentication.RedirectfromLoginPage·½·¨½«ÒÑÑéÖ¤µÄÓû§Öض¨Ïòµ½Óû§¸Õ²ÅÇëÇóµÄÒ³Ãæ.¾ßÌåµÄʵÀýÇë²Î¿¼:
¡¡¡¡FormsÑéÖ¤ http://www.fanvb.net/web
Ïà¹ØÎĵµ£º
´úÂë:
/// <summary>
/// ´ò¿ªExcelÎļþ
/// </summary>
/// <param name="ExcelFileName">ÎļþÃû</param>
private void OpenExcelFile(string ExcelFileName)
{
&nb ......
³ö´¦£º¶¯Ì¬ÍøÕ¾ÖÆ×÷Ö¸ÄÏ ×÷Õߣº¶¯Ì¬ÍøÕ¾ÖÆ×÷Ö¸ÄÏ Ê±¼ä£º2006-3-20 12:40:00
Ò»¸öÎüÒýÈ˵ġ¢¹¦ÄÜÍ걸µÄÍøÕ¾ÍùÍù¾ßÓÐÒÔÏÂÌØÕ÷£ºÒ»ÊÇÄÚÈݳäʵ¡¢ÊµÓã¬ÎüÒý¶Ô¸ÃÀàÄÚÈݸÉÐËȤµÄä¯ÀÀÕߣ»¶þÊÇÒ³ÃæÉèÖúÏÀí£¬Ò³ÃæÉè¼Æ¾«ÃÀ£»ÈýÊÇÍøÕ¾»¥¶¯ÐÔÇ¿£¬Óû§ºÍÍøÕ¾»òÕßÓû§ÓëÓû§Ö®¼ä½»Á÷·½±ã¸ßЧ£»ËÄÊÇÍøÕ¾ÄÚÈݸüм°Ê±²¢ÇÒ¿ ......
ÔÚÌض¨Ìõ¼þÏ£¬Äú¿ÉÄÜÐèÒª±Ü¿ªÑéÖ¤¡£ÀýÈ磬Äú¿ÉÄܾßÓÐÒ»¸öÒ³Ã棬¼´Ê¹Óû§Ã»ÓÐÕýÈ·ÌîдËùÓÐÑéÖ¤×ֶΣ¬Ò²Ó¦¸Ã¿ÉÒÔ·¢ËÍÒ³¡£Äú¿ÉÒÔÉèÖà ASP.NET ·þÎñÆ÷¿Ø¼þÀ´±Ü¿ª¿Í»§¶ËºÍ·þÎñÆ÷µÄÑéÖ¤£¬¶ø²»Ö»ÊÇ¿Í»§¶ËÑéÖ¤¡£
°²È«ËµÃ÷£º ĬÈÏÇé¿öÏ£¬ASP.NET ÍøÒ³Ö´ÐÐÇëÇóÑéÖ¤ÒÔÈ·±£Óû§ÊäÈëÄÚÈݲ»°üº¬½Å±¾» ......
µ÷ÓÃÊý¾ÝÁ¬½ÓÁ½ÖÖ·½·¨
1.web.config £¨ÅäÖÃÎļþ£© ÖÐ
<appSettings>
<add key="ConnectionString" value="server=localhost\sqlexpress;uid=sa;pwd=123456;database=News"/>
</appSettings>
µ÷ÓõÄʱºò
string strConn = System.Configuration.ConfigurationManager.AppSettings["ConnectionString ......