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

ASP.NET MVC Best Practices 27+

12 ASP.NET MVC Best Practices
M
DomainModel != ViewModel
Use ActionFilters for “shared” data
V
Do NEVER user code-behind
Write HTML each time you can
If there is an if, write an HtmlHelper
Choose your view engine carefully
C
Delete the AccountController
Isolate Controllers from the outside World
Use an IoC Container
Say NO to “magic strings”
Build your own “personal conventions”
Pay attention to the Verbs 
 
ASP.NET MVC Best Practices
Use
Use jQuery and jQuery UI
Use Bootstrapper in Global.asax
Use Action Filter to Convert to compatible Action Methods parameters
Use UpdateModel Carefully
Use PRG Pattern for Data Modification
Do Not
Do not make any hard dependency on the DI Container, use Common Service Locator
Do not put your JavaScript codes in your View
Avoid ViewData, use ViewData.Model
Do not make any hard dependency on the DI Container, use Common Service Locator
Controller will not contain any Domain logic
Decorate
Decorate your most frequent Action Methods with OutputCache Attribute
Decorate your Action Methods with Proper AcceptVerbs Attribute
Decorate your most frequent Action Methods with OutputCache Attribute
Decorate your Action Methods with Proper AcceptVerbs Attribute
Create
Create new ActionResult if required
Create Extension methods of UrlHelper to generate your url from Route
Create Layer Super Type for your ViewModel and Use Action Filter to populate common parts.
Create Extension Method of UrlHelper to map your JavaScript, Stylesheet and Image Folder
HtmlHelper extension
Split your View into multiple ViewUserControl
Tips
Routing consideration
Encode
Action Filter Location
Keep your controller free from HttpContext and its tail
Ô­ÎĵØÖ·£º
http://weblogs.asp.net/rashid/archive/2009/04/01/asp-net-mvc-best-practices-part-1.aspx
http://codeclimber.net.nz/archive/2009/10/27/12-asp.net-mvc-best-practices.aspx
 


Ïà¹ØÎĵµ£º

ASP.NETʹÓÃRequest»ñÈ¡À´Ô´ÍøÖ·URL²ÎÊý

Request¶ÔÏó¹¦ÄÜÊÇ´Ó¿Í»§¶ËµÃµ½Êý¾Ý£¬³£ÓõÄÈýÖÖÈ¡µÃÊý¾ÝµÄ·½·¨ÊÇ£ºRequest.Form¡¢Request.QueryString£¬Request¡£ÆäµÚÈýÖÖÊÇÇ°Á½ÖÖµÄÒ»¸öËõд£¬¿ÉÒÔÈ¡´úÇ°Á½ÖÖÇé¿ö¡£¶øÇ°Á½ÖÖÖ÷Òª¶ÔÓ¦µÄFormÌύʱµÄÁ½ÖÖ²»Í¬µÄÌá½»·½·¨£º·Ö±ðÊÇPost·½·¨ºÍGet·½·¨¡£
        Request ¶ÔÏóµÄÊôÐԺͷ½·¨± ......

ASP.NETÖÐFCKeditor_2.6.3ÅäÖÃ

FCKeditor½éÉÜ
¡¡¡¡FCKeditorÊÇÒ»¸ö¹¦ÄÜÇ¿´óÖ§³ÖËù¼û¼´ËùµÃ¹¦ÄܵÄÎı¾±à¼­Æ÷£¬¿ÉÒÔΪÓû§Ìṩ΢ÈíofficeÈí¼þÒ»ÑùµÄÔÚÏßÎĵµ±à¼­·þÎñ¡£Ëü²»ÐèÒª°²×°ÈκÎÐÎʽµÄ¿Í»§¶Ë£¬¼æÈݾø´ó¶àÊýÖ÷Á÷ä¯ÀÀÆ÷£¬Ö§³ÖASP.Net¡¢ASP¡¢ColdFusion ¡¢PHP¡¢Java¡¢Active-FoxPro¡¢Lasso¡¢Perl¡¢ython µÈ±à³Ì»·¾³¡£
¡¡¡¡¹Ù·½ÍøÕ¾http://www.fckedit ......

ASP.NETÒ³ÃæÖ¸Áî

ASP.NETÖ¸ÁîÔÚÿ¸öASP.NETÒ³ÃæÖж¼ÓС£Ê¹ÓÃÕâЩָÁî¿ÉÒÔ¿ØÖÆASP.NETÒ³ÃæµÄÐÐΪ¡£ÏÂÃæÊÇPageÖ¸ÁîµÄÒ»¸öÀý×Ó£º
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
    Inherits="_Default" %>
ÔÚASP.NETÒ³Ãæ»òÓû§¿Ø¼þÖÐÓÐ11¸öÖ¸Áî¡£ÎÞÂÛÒ³ÃæÊÇʹÓúǫ́±àÂëÄ£ÐÍ»¹ÊÇÄÚÖñ ......

ASP.NETÒ³Ãæ¶ÔÏó

   »ñÈ¡ÇëÇóµÄÒ³µÄ HttpRequest ¶ÔÏó¡£
Ò»¡¢HttpRequest Àà
ʹ ASP.NET Äܹ»¶ÁÈ¡¿Í»§¶ËÔÚ Web ÇëÇóÆڼ䷢Ë굀 HTTP Öµ¡£
      ÏÂÃæµÄ´úÂëʾÀýʹÓà StreamWriter ÀཫÈô¸É HttpRequest ÀàÊôÐÔÖµµÄֵдÈëÎļþ¡£¶ÔÓÚÊÇ×Ö·û´®ÀàÐ͵ÄÊôÐÔ£¬ÊôÐÔÖµ±»Ð´ÈëÎļþʱ½«±»±àÂëΪ HTML¡£±íʾ¼¯ºÏµ ......

ASP.NETÒ³Ãæ¶ÔÏó

   »ñÈ¡ÇëÇóµÄÒ³µÄHttpApplicationState ¶ÔÏó¡£
Ò»¡¢HttpApplicationState Àà
      ×÷ÓãºÆôÓà ASP.NET Ó¦ÓóÌÐòÖжà¸ö»á»°ºÍÇëÇóÖ®¼äµÄÈ«¾ÖÐÅÏ¢¹²Ïí¡£
      ASP.NET Ó¦ÓóÌÐòµÄ¸ÅÄÊǵ¥¸ö Web ·þÎñÆ÷ÉϵÄij¸öÐéÄâĿ¼¼°Æä×ÓĿ¼·¶Î§ÄÚµÄËùÓÐÎļþ¡¢Ò³¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ