asp.net formÑéÖ¤
Asp.netµÄÉí·ÝÑéÖ¤ÓÐÓÐÈýÖÖ£¬·Ö±ðÊÇ"Windows | Forms | Passport"£¬ÆäÖÐÓÖÒÔFormsÑéÖ¤ÓõÄ×î¶à£¬Ò²×îÁé»î¡£
Forms ÑéÖ¤·½Ê½¶Ô»ùÓÚÓû§µÄÑéÖ¤ÊÚȨÌṩÁ˺ܺõÄÖ§³Ö£¬¿ÉÒÔͨ¹ýÒ»¸öµÇ¼ҳÃæÑéÖ¤Óû§µÄÉí·Ý£¬½«´ËÓû§µÄÉí·Ý·¢»Øµ½¿Í»§¶ËµÄCookie£¬Ö®ºó´ËÓû§ÔÙ·ÃÎÊÕâ¸öwebÓ¦ÓþͻáÁ¬Í¬Õâ¸öÉí·ÝCookieÒ»Æð·¢Ë͵½·þÎñ¶Ë¡£·þÎñ¶ËÉϵÄÊÚȨÉèÖþͿÉÒÔ¸ù¾Ý²»Í¬Ä¿Â¼¶Ô²»Í¬Óû§µÄ·ÃÎÊÊÚȨ½øÐпØÖÆÁË¡£
ÎÊÌâÀ´ÁË£¬ÔÚʵ¼ÊÊÇÓÃÖÐÎÒÃÇÍùÍùÐèÒªµÄÊÇ»ùÓÚ½ÇÉ«£¬»òÕß˵»ùÓÚÓû§×éµÄÑéÖ¤ºÍÊÚȨ¡£¶ÔÒ»¸öÍøÕ¾À´Ëµ£¬Ò»°ãµÄÑéÖ¤ÊÚȨµÄģʽӦ¸ÃÊÇÕâÑùµÄ£º¸ù¾Ýʵ¼ÊÐèÇó°ÑÓû§·Ö³É²»Í¬µÄÉí·Ý£¬¾ÍÊǽÇÉ«£¬»òÕß˵ÊÇÓû§×飬ÑéÖ¤¹ý³Ì²»µ«ÒªÑéÖ¤Õâ¸öÓû§±¾ÉíµÄÉí·Ý£¬»¹ÒªÑéÖ¤ËüÊÇÊôÓÚÄĸö½ÇÉ«µÄ¡£¶ø·ÃÎÊÊÚȨÊǸù¾Ý½ÇÉ«À´ÉèÖõģ¬Ä³Ð©½ÇÉ«¿ÉÒÔ·ÃÎÊÄÄЩ×ÊÔ´£¬²»¿ÉÒÔ·ÃÎÊÄÄЩ×ÊÔ´µÈµÈ¡£ÒªÊÇ»ùÓÚÓû§À´ÊÚȨ·ÃÎʽ«»áÊǸöºÜ²»Êµ¼ÊµÄ×ö·¨£¬Óû§Óкܶ࣬»¹¿ÉÄÜËæʱµÄÔö¼õ£¬²»¿ÉÄÜÔÚÅäÖÃÎļþÖÐËæʱµÄΪ²»¶ÏÔö¼ÓµÄÐÂÓû§È¥Ôö¼Ó·ÃÎÊÊÚȨµÄ¡£
ÏÂÃæ´ó¸ÅµÄ¿´Ò»ÏÂFormsµÄ¹ý³Ì¡£
FormsÉí·ÝÑéÖ¤»ù±¾ÔÀí£º
Ò» Éí·ÝÑéÖ¤
Òª²ÉÓÃFormsÉí·ÝÑéÖ¤£¬ÏÈÒªÔÚÓ¦ÓóÌÐò¸ùĿ¼ÖеÄWeb.configÖÐ×öÏàÓ¦µÄÉèÖÃ:
<authentication mode="forms">
<forms name=".ASPXAUTH " loginUrl="/login.aspx" timeout="30" path= "/">
</forms>
</authentication>
ÆäÖÐ<authentication mode= "forms"> ±íʾ±¾Ó¦ÓóÌÐò²ÉÓÃFormsÑéÖ¤·½Ê½¡£
1. <forms>±êÇ©ÖеÄname±íʾָ¶¨ÒªÓÃÓÚÉí·ÝÑéÖ¤µÄ HTTP Cookie¡£Ä¬ÈÏÇé¿öÏ£¬name µÄÖµÊÇ .ASPXAUTH¡£²ÉÓôËÖÖ·½Ê½ÑéÖ¤Óû§ºó,ÒÔ´ËÓû§µÄÐÅÏ¢½¨Á¢Ò»¸öFormsAuthenticationTicketÀàÐ͵ÄÉí·ÝÑé֤Ʊ,ÔÙ¼ÓÃÜÐòÁл¯ÎªÒ»¸ö×Ö·û´®,×îºó½«Õâ¸ö×Ö·û´®Ð´µ½¿Í»§¶ËµÄnameÖ¸¶¨Ãû×ÖµÄCookieÖÐ.Ò»µ©Õâ¸öCookieдµ½¿Í»§¶Ëºó,´ËÓû§ÔٴηÃÎÊÕâ¸öwebÓ¦ÓÃʱ»á½«Á¬Í¬CookieÒ»Æð·¢Ë͵½·þÎñ¶Ë,·þÎñ¶Ë½«»áÖªµÀ´ËÓû§ÊÇÒѾÑéÖ¤¹ýµÄ.
ÔÙ¿´Ò»ÏÂÉí·ÝÑé֤Ʊ¶¼°üº¬ÄÄЩÐÅÏ¢ÄØ,ÎÒÃÇ¿´Ò»ÏÂFormsAuthenticationTicketÀà:
CookiePath£º ·µ»Ø·¢³ö Cookie µÄ·¾¶¡£×¢Ò⣬´°ÌåµÄ·¾¶ÉèÖÃΪ /¡£ÓÉÓÚ´°ÌåÇø·Ö´óСд£¬ÕâÊÇΪÁË·ÀÖ¹Õ¾µãÖÐµÄ URL µÄ´óСд²»Ò»Ö¶ø²ÉÈ¡µÄÒ»ÖÖ±£»¤´ëÊ©¡£ÕâÔÚˢРCookie ʱʹÓÃ
Expiration£º »ñÈ¡ Cookie ¹ýÆÚµÄÈÕÆÚ/ʱ¼ä¡£
IsPersistent£º Èç¹ûÒÑ·¢³ö³Ö¾ÃµÄ Cookie£¬Ôò·µ»Ø true¡£·ñÔò£¬Éí·ÝÑéÖ¤ Cookie ½«Ï
Ïà¹ØÎĵµ£º
ASP.NET 4µÄWeb Formsµ±ÖУ¬×îÁîÈ˼¤É͵ģ¬ÔòĪ¹ýÓÚÊÇURL Routing»úÖƵÄÈ«ÃæÖ§³Ö¡£¹ýÈ¥ÔÚASP.NET 3.5 SP1µ±ÖУ¬Web Forms»ò¶à»òÉپͿªÊ¼Ö§³ÖURL Routing»úÖÆ£¬ËüÈÃÎÒÃÇÔÚÍøÖ·µÄ³ÊÏÖÒÔ¼°Ê¹ÓÃÉϸü¼ÓµÄÓе¯ÐÔ¡£
¹ýÈ¥ÎÒÃÇÔÚASP.NETµ±ÖУ¬Ï°¹ßÓÚµ×ÏÂÕâÑùµÄÍøÖ·³ÊÏÖ·½Ê½£º
http://myWebSite/EditProduct.aspx?Id=1
µ«×î½ü¼¸ÄêR ......
using System.Text.RegularExpressions;
Regex reg = new Regex(@"^\d+$"); //ÑéÖ¤×Ö·û´®
Response.Write( reg.IsMatch(""));
Response.Write(reg.IsMatch("sf"));
Response.Write ......
ASP.NET»ñÈ¡ÌìÆøÔ¤±¨´óÖ·ÖÎöÓÐ 1µ½Ä³¸öÍøÕ¾ÉÏ·ÖÎöÍøÕ¾µÄ´úÂë»ñÈ¡£»2×Ô¼ºÐ´Çý¶¯·þÎñºÍweb·þÎñ µÚ¶þÖÖˮ̫Éî²»ÔøÉæ¼°¡£
ASP.NETºǫ́³ÌÐò»ñÈ¡ÖÐÑëÆøÏǫ́ÌìÆøÔ¤±¨
1.ÌìÆø·â×°³ÉÒ»¸öʵÌå
2.¿ÉÒÔ»ñÈ¡µ±ÌìÌìÆø£¬Ò²¿ÉÒÔ»ñȡδÀ´ÎåÌìµÄÌìÆø¼¯ºÏ
using System;
using System.Collections.Generic;
using System.Text;
......
Request¶ÔÏó¹¦ÄÜÊÇ´Ó¿Í»§¶ËµÃµ½Êý¾Ý£¬³£ÓõÄÈýÖÖÈ¡µÃÊý¾ÝµÄ·½·¨ÊÇ£ºRequest.Form¡¢Request.QueryString£¬Request¡£ÆäµÚÈýÖÖÊÇÇ°Á½ÖÖµÄÒ»¸öËõд£¬¿ÉÒÔÈ¡´úÇ°Á½ÖÖÇé¿ö¡£¶øÇ°Á½ÖÖÖ÷Òª¶ÔÓ¦µÄFormÌύʱµÄÁ½ÖÖ²»Í¬µÄÌá½»·½·¨£º·Ö±ðÊÇPost·½·¨ºÍGet·½·¨¡£
Request ¶ÔÏóµÄÊôÐԺͷ½·¨± ......
Asp.Net ±¸·ÝºÍ»Ö¸´SQL SERVER Êý¾Ý¿â
ÎÒÃÇͨ³£±¸·ÝÊý¾Ý¿âʱ£¬ÐèÒªµÇ¼Êý¾Ý¿â·þÎñÆ÷È¥±¸·ÝºÍ»Ö¸´£¬ÕâÑùºÜ²»·½±ã£¬ÆäʵSQL SERVER×Ô´øµÄÃüÁî¿ÉÄÜÈÃÎÒÃǺܼòµ¥µØʵÏÖÔ¶³Ìͨ¹ýAsp.Net±¸·ÝºÍ»Ö¸´Êý¾Ý¿â¡£
BACKUP DATABASE '±»±¸·ÝµÄÊý¾Ý¿âÃû' TO DISK = '±¸·ÝÎļþ·¾¶';
ALTER DATABASE '±»»Ö¸´µÄÊý¾Ý¿âÃû' ......