13¸ö²»¿É²»ÖªµÄASP.NET MVCÀ©Õ¹µã
ASP.NET MVCÉè¼ÆµÄÖ÷ÒªÔÔòÖ®Ò»ÊÇ¿ÉÀ©Õ¹ÐÔ¡£´¦Àí¹ÜÏߣ¨processing pipeline£©ÉϵÄËùÓУ¨»ò´ó¶àÊý£©¶«Î÷¶¼ÊÇ¿ÉÌæ»»µÄ¡£Òò´Ë£¬Èç¹ûÄú²»Ï²»¶ASP.NET MVCËùʹÓõÄÔ¼¶¨£¨»òȱ·¦Ä³Ð©Ô¼¶¨£©£¬Äú¿ÉÒÔ´´½¨×Ô¼ºµÄ·þÎñÀ´Ö§³ÖÄúµÄÔ¼¶¨£¬²¢½«Æä×¢Èëµ½Ö÷¹ÜÏßÖС£
ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«´Ó¹ÜÏß¿ªÊ¼Ö±µ½ÊÓͼ³ÊÏÖ£¬ÖðÒ»ÏòÄúչʾÿ¸öASP.NET MVC¿ª·¢Õ߶¼±ØÐëÁ˽â13¸öÀ©Õ¹µã¡£
1.ASP.NET MVCÀ©Õ¹Ö®RouteConstraint
ͨ³£Çé¿öÏÂÄã¿ÉÒÔʹÓÃÕýÔò±í´ïʽ¶Ôurl²ÎÊý½øÐÐÔ¼Êø£¬µ«Èç¹ûÄúµÄÔ¼Êø²»½ö½öÈ¡¾öÓÚµ¥Ò»²ÎÊý£¬Äú¿ÉÒÔʵÏÖ IRouteConstrainsµÄ·½·¨£¬²¢ÔÚÆäÖÐÌí¼ÓÄãµÄÑéÖ¤Âß¼¡£
±ÈÈç¶ÔÈÕÆÚµÄÑéÖ¤£¬urlÖпÉÄÜ»á°üº¬Äê¡¢Ô¡¢ÈÕ£¬¶øÄãÐèÒªÑéÖ¤ÕâÈýÕßÊÇ·ñ¿ÉÒÔ×éºÏ³ÉÒ»¸öÓÐЧµÄÈÕÆÚ¡£
2.ASP.NET MVCÀ©Õ¹Ö®RouteHandler
RouteHandlerÊÇÔÚ·ÓÉÑ¡ÔñÖ®ºó½øÐд¦ÀíµÄ×é¼þ£¬Ëü²¢²»½ö½öÕë¶ÔASP.NET MVC¡£ÏÔÈ»£¬Èç¹ûÄú¸Ä±äÁËRouteHandler£¬ÄÇô¶ÔÇëÇóµÄ´¦Àí½«²»ÔÙʹÓÃASP.NET MVC£¬µ«ÕâÔÚÄúʹÓÃÆäËûHttpHandler»ò¾µäµÄWebForm½øÐзÓÉ´¦ÀíʱȴÊǷdz£ÓÐÓõġ£
3.ASP.NET MVCÀ©Õ¹Ö®ControllerFactory
ControllerFactoryÊÇ»ùÓÚ·ÓɵÄ×é¼þ£¬ËüÑ¡ÔñÕýÈ·µÄcontroller²¢¶ÔÆäʵÀý»¯¡£ default factory»á²éÕÒʵÏÖÁËIController²¢ÇÒÒÔController½áβµÄÀ࣬Ȼºóͨ¹ý·´ÉäʹÓÃÎ޲ι¹Ô캯Êý½øÐÐʵÀý»¯¡£
µ«Èç¹ûÄúÏ£ÍûʹÓÃÒÀÀµ×¢È룬¾Í²»ÄÜÔÙʹÓÃdefault factory£¬¶ø±ØÐëʹÓÃÖ§³ÖIoCµÄcontroller factory¡£MvcContribºÍNinject Controller Factory¶¼°üº¬Ö§³ÖIoCÈÝÆ÷µÄcontroller factory¡£
4.ASP.NET MVCÀ©Õ¹Ö®ActionInvoker
ActionInvoker¹ËÃû˼ÒåÊǸºÔðµ÷Óã¨invoke£©actionµÄ¡£Ä¬ÈϵÄaction invokerͨ¹ý·½·¨Ãû¡¢actionÃû»òÆäËû¿ÉÄܵÄselector attributeÀ´²éÕÒaction£¬È»ºóµ÷ÓÃaction·½·¨ÒÔ¼°¶¨ÒåµÄfilter£¬×îÖÕÖ´Ðеõ½action result¡£
Äã»á·¢Ïִ󲿷ÖÖ´ÐйÜÏß´æÔÚÓÚControllerActionInvokerÀàµÄÂß¼Ö®ÖС£Òò´Ë£¬Èç¹ûÏ£Íû¸Ä±äÕâЩԼ¶¨£¬Èçaction·½·¨µÄÑ¡ÔñÂß¼¡¢http²ÎÊýÓ³Éäµ½action²ÎÊýµÄ·½Ê½¡¢Ñ¡ÔñºÍÖ´ÐÐfilterµÄ·½Ê½µÈ£¬ÄúÐèÒªÀ©Õ¹¸ÃÀಢÖØдÐèÒªÐ޸ĵķ½·¨¡£
¿ÉÒÔ²ÎÔÄNinjectActionInvoker I developed to allow injection of dependencies inside filters¡£
5.ASP.NET MVCÀ©Õ¹Ö®ActionMethodSelectorAttribute
ʹÓÃĬÈϵÄaction invokerʱ£¬actionµÄÑ¡ÔñÊÇ»ùÓÚÃû³ÆµÄ¡£ÄúÒ²¿ÉÒÔʵÏÖ×Ô¼ºµÄMethod SelectorÒÔ¸ÄÉƶÔÓÚactionµÄÑ¡Ôñ¡£ÔÚ¿ò¼ÜÖÐÒѾ°üº¬ÁËAcceptVerbsÌØÐÔ£¬ËüÔÊÐíÄúÖ¸¶¨Ê¹ÓÃÄÄ
Ïà¹ØÎĵµ£º
×î½ü×öÒ»¸öÍøÕ¾£¬ÀïÃæÉæ¼°µ½¼¶ÁªµÄÎÊÌ⣨ÈçÊ¡-ÊУ¬Æ·ÅÆ-ÐͺŵÈ), ÎÒÓõÄÊÇDropDownListÀ´ÊµÏֵģ¬ÉèÖø¸¼¶µÄAutoPostBackÊôÐÔΪÕæ.È»ºóÔÚËüµÄSelectedIndexChanged()ʼþÀïдÏàÓ¦µÄ´úÂ룬ÕâÑù¾ÍÄÜʵÏÖ¼¶Áª¹Øϵ£¨µ±È»ÕâÀïҪעÒâIsPostBackµÄÎÊÌ⣩. ×öºÃÖ®ºóÓÃʱ·¢ÏÖÒ»¸ö·Ç³£²»Ë¬µÄÎÊÌ⣬ÄǾÍÊÇÿ´Î¶¼»áˢУ¬Õ ......
ASP.net »ñµÃ¿Í»§¶ËµÄIP£¬×î³£¼ûµÄÊÇʹÓÃÏÂÊö´úÂ룺
string user_IP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
¶ÔÓÚÁ˽â´úÀí·þÎñÆ÷Çé¿öµÄÈË£¬ÎÒÃÇ»áÖªµÀ£¬Èç¹ûÓû§Ê¹ÓÃÁË´úÀí·þÎñÆ÷£¬ÉÏÊö´úÂë»ñµÃµÄÊÇ´úÀí·þÎñÆ÷µÄIPµØÖ·£»Èç¹ûÓû§Ê¹ÓÃÁ˶à¸ö´úÀí·þÎñÆ÷£¬ÔòÊǵ½´ï·þÎñÆ÷µÄ×îºóÒ»¸ö´úÀí· ......
MysqlµÄconnector/net5.0ÏÂÔصØÖ·:
http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-5.0.6.zip/from/pick
°²×°ºÃÒÔºó,
µãÊôÐÔ,È»ºóµã²éÕÒÄ¿±ê,µãÏòÉÏÒ»²ãĿ¼,ÕÒµ½Binaries\.NET 2.0,È»ºó½«Õâ¸öÎļþ¸´ÖƵ½ÄãµÄ¹¤³ÌĿ¼ÏÂ,Ò»°ãÕâÑùµÄDLLÎļþ»á±£´æµ½binĿ¼ÏÂ.
ÔÚ´úÂëÒ³ÀïÊäÈëusing Mysql. ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
StartClientCaching();
......
ת×Ôhttp://martinyang2010.bokee.com/2598999.html
using System;
using System.Data;
using System.Drawing;
using System.Data.SqlClient;
using Excel;
using Word;
using System.IO;
namespace Common
{
/// <summary>
/// °ÑÊý¾Ýµ¼Èëµ½.doc¡¢.txt¡¢.xlsÎļþÖÐ
/// </summary>
publi ......