Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ASP.NET MVC ÈëÃÅ

ÓÐʱºòÄãÏëÔÚµ÷ÓÃaction·½·¨Ö®Ç°»òÕßaction·½·¨Ö®ºó´¦ÀíһЩÂß¼­£¬ÎªÁËÖ§³ÖÕâ¸ö£¬ASP.NET MVCÔÊÐíÄã´´½¨action¹ýÂËÆ÷¡£Action¹ýÂËÆ÷ÊÇ×Ô¶¨ÒåµÄAttributes£¬ÓÃÀ´±ê¼ÇÌí¼ÓAction·½·¨Ö®Ç°»òÕßAction·½·¨Ö®ºóµÄÐÐΪµ½¿ØÖÆÆ÷ÀàÖеÄAction·½·¨ÖС£
һЩ¿ÉÄÜÓõ½Action¹ýÂËÆ÷µÄµØ·½ÓУº
ÈÕÖ¾,Òì³£´¦Àí
Éí·ÝÑéÖ¤ºÍÊÚȨ £­ ÏÞÖÆÓû§µÄ·ÃÎÊ
Êä³ö»º´æ £­ ±£´æÒ»¸öActionµÄ½á¹û
ÍøÂçÅÀ³æµÄ¹ýÂË
±¾µØ»¯
¶¯Ì¬Action £­ ½«Ò»¸öAction×¢Èëµ½¿ØÖÆÆ÷ÖÐ
ASP.NET MVCΪÎÒÃÇÌṩÁËÏÂÃæµÄ¼¸¸öFilter½Ó¿Ú£º
IActionFilter
IAuthorizationFilter
IExceptionFilter
IResultFilter
ҪʵÏÖÒ»¸öFilter£¬ÎÒÃÇÐèÒª¼Ì³Ð×ÔFilterAttributeÀàͬʱʵÏÖÉÏÃæµÄÒ»¸ö»ò¼¸¸ö½Ó¿Ú£º
public class MyFilter : FilterAttribute, IActionFilter, IResultFilter
{

 
Õ⼸¸ö½Ó¿ÚÌṩµÄ·½·¨ÈçÏ£º

ÉÏͼµÄ·½·¨ºÍFilter½Ó¿Ú¶ÔÓ¦µÄ·½·¨°´Ãû³Æ¶ÔºÅÈë×ù¾Í¿ÉÒÔ¡£
IActionFilter½Ó¿ÚÓÐÁ½¸ö·½·¨£º

ÆäÖÐOnActionExecutingÔÚÖ´ÐÐAction·½·¨Ö®Ç°»á±»µ÷Óã¬OnActionExecuted»áÔÚAction·½·¨Ö´Ðкóµ÷Óá£×¢ÒâËûÃǵIJÎÊý·Ö±ðÊÇActionExecutingContextºÍActionExecutedContext¡£
ActionExecutedContextÀà°üº¬Ò»¸ö CanceledµÄÊôÐÔ£¬ÔÊÐíÄãÈ¡Ïûµ±Ç°µÄAction(ÔõôԭÀ´ÔÚP3ÖÐÊÇÔÚActionExecutingContextµÄCanceledÊôÐÔÔÚP5ÖÐûÓÐÁËÄØ£¿ÉñÆæ.ÄÇôÔÚOnActionExecutingµÄʱºòÔõôȡÏûÒ»¸öActionÄØ£¿)¡£
FilterExcutedContext Àà°üº¬Ò»¸öExceptionÊôÐÔºÍÒ»¸öExceptionHandledÊôÐÔ¡£Èç¹ûExceptionÊôÐÔΪnull£¬ÔòûÓÐÒì³£ÔÚaction stackÖУ¬±íÃ÷Action·½·¨ÔËÐв¢Ã»Óз¢Éú´íÎó¡£·´Ö®ÔòΪ³öÏÖÒì³£¡£Èç¹û½«ExceptionHandledÊôÐÔÉèÖÃΪtrueÔò±íÃ÷ÔÚÕâ¸öFilterÖÐÒѾ­´¦ÀíÁËÒì³£¡£
IResultFilter½Ó¿ÚÒ²ÌṩÁËÁ½¸ö·½·¨£º

ËûÃÇ·Ö±ðÔÚAction·µ»Ø½á¹û(ÀýÈçreturn View();)֮ǰºÍÖ®ºóÖ´ÐС£ºÍIActionFilter²î²»¶à¾Í²»¶à˵ÁË¡£
IAuthorizationFilterÊÇÒ»¸öÓÃÓÚÉí·ÝÑéÖ¤µÄFilter¡£Ö»ÌṩÁËÒ»¸övoid OnAuthorization(AuthorizationContext filterContext)·½·¨¡£
IExceptionFilter»áÔÚ³öÏÖÒì³£µÄʱºòµ÷Óã¬Ò²ÊÇÖ» Ìṩһ¸övoid OnException(ExceptionContext filterContext)µÄ·½·¨£»
ÕâЩFilter¿ÉÒÔ±»Ó¦ÓÃÔÚÀà»òÕß·½·¨ÉÏ£¬ÏÂÃæÎÒÃÇÀ´¿´Ò»ÏÂËûÃǵÄÖ´ÐÐ˳Ðò¡£Ê×ÏÈÎÒÃÇдһ¸öBaseController²¢¼ÓÉÏÁ½¸öFilter£º
[MyFilter2(Target =&nb


Ïà¹ØÎĵµ£º

asp.net µ÷Óô洢¹ý³Ì

1.»ñÈ¡Return·µ»ØÖµ
 ³ÌÐò´úÂë//´æ´¢¹ý³Ì
//Create PROCEDURE MYSQL
//     @a int,
//     @b int
//AS
//     return @a + @b
//GO
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToStri ......

ASP.NET²Ù×÷Cookie

//´´½¨
HttpCookie cookie = new HttpCookie("user","111");//´´½¨Cookie
cookie Expires = DateTime.Now.Add(15);//ÉèÖùýÆÚʱ¼ä
 Response.Cookies.Add(cookie);//´æÈë¿Í»§¶Ë
ÎÒÃÇÈ¡³öCookieÖµÒ²ºÜ¼òµ¥
string value = Request.Cookies["user"].value;
ÓÐʱºòÎÒÃÇÏëÔÚÒ»¸öCookieÖд¢´æ¶à¸öÐÅÏ¢£¬ÄÇÒ ......

ASP.NET ״̬·þÎñ ¼° session¶ªÊ§ÎÊÌâ½â¾ö·½°¸×ܽá

 
asp.net SessionµÄʵÏÖ£º
asp.netµÄSessionÊÇ»ùÓÚHttpModule¼¼Êõ×öµÄ£¬HttpModule¿ÉÒÔÔÚÇëÇó±»´¦Àí֮ǰ£¬¶ÔÇëÇó½øÐÐ״̬¿ØÖÆ£¬ÓÉÓÚSession±¾Éí¾ÍÊÇÓÃÀ´×ö״̬ά»¤µÄ£¬Òò´ËÓÃHttpModule×öSessionÊÇÔÙºÏÊʲ»¹ýÁË¡£
ASP.NETÖÐSessionµÄ״̬±£³Ö·½Ê½
ASP.NETÌṩÁËSession¶ÔÏ󣬴ӶøÔÊÐí³ÌÐòԱʶ±ð¡¢´æ´¢ºÍ´¦Àíͬһ ......

asp.net°²È«ÎÊÌâ

 ÎåÖÖ³£¼ûµÄASP.NET°²È«È±ÏÝ
±£Ö¤Ó¦ÓóÌÐòµÄ°²È«Ó¦µ±´Ó±àдµÚÒ»ÐдúÂëµÄʱºò¿ªÊ¼×öÆð£¬Ô­ÒòºÜ¼òµ¥£¬Ëæ×ÅÓ¦ÓùæÄ£µÄ·¢Õ¹£¬ÐÞ²¹°²È«Â©¶´ËùÐèµÄ´ú¼ÛÒ²ËæÖ®¿ìËÙÔö³¤¡£¸ù¾ÝIBMµÄϵͳ¿ÆѧЭ»á£¨Systems Sciences Institute£©µÄÑо¿£¬Èç¹ûµÈµ½Èí¼þ²¿ÊðÖ®ºóÔÙÀ´ÐÞ²¹È±ÏÝ£¬Æä´ú¼ÛÏ൱ÓÚ¿ª·¢ÆÚ¼ä¼ì²âºÍÏû³ýȱÏݵÄ15±¶¡£
¡¡¡¡Î ......

Èà ASP.Net MVC µÄURL¿´ÉÏÈ¥Ïñ¸ö´«Í³WebFormµÄURL

ÔÚIIS6Éϲ¿Êð¹ýASP.Net MVCµÄÒ»¶¨ÖªµÀ£¬ÎªÁËÄÜÈÃIIS½«¶ÔASP.Net MVCµÄÇëÇóת·¢¸øASP.Net´¦Àí£¬±ØÐëÌí¼ÓÓ¦ÓóÌÐòISAPIÓ³Éä¡£ ±ÜÃâÕâÖÖÓ³ÉäÌí¼ÓµÄÒ»ÖÖ·½·¨ÊÇÀûÓÃÒÑÓеÄÓ³É䣬ÀýÈç.aspxÀ©Õ¹ÃûµÄÓ³Éä¡£²»¹ýÄÇÑùµÄ»°ASP.Net MVCµÄUrl»áºÜ¡°ÄÑ¿´¡±£¬¡°http://localhost/ASPNETMVCAPP/Account.aspx/Logon/¡±¡£Èç¹ûÄÜ°ÑÆäÖеÄ.a ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ