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

Using StructureMap with the ASP.NET MVC framework

 Ô­ÎĵØÖ·:http://www.bengtbe.com/blog/post/2009/02/27/Using-StructureMap-with-the-ASPNET-MVC-framework.aspx
Using StructureMap with the ASP.NET MVC framework
2009-02-27 ÐÇÆÚÎå ×÷Õß:bengtbe
ÔÚÕâÀïÎÒÒª²ûÊöµÄÊÇÔõôÓÃ.net frameword ¿ò¼ÜϵÄStructureMapÕâ¸öÀà.  
ÔÚѧϰÕâ¸öÖ®¼äÄãÐèÒª¶ÔASP.NET MVC¿ò¼Ü£¬ÒÀÀµ×¢ÈëºÍ¿ØÖÆ·´×ªÓлù±¾µÄÁ˽⡣
ÕâЩ¼¼ÊõÒ²²»Ö»ÓÃÓÚ StructureMap £¬Èç¹ûÄãϲ»¶ÕâЩ£¬ÄÇôÄ㵱ȻҲÓÃÆäËüµÄDI/Ioc  ¹¤¾ßÁË¡£
ÎÒÃǾÍÓÃÕâ¸öUserController Àý×Ó»¹ËµÆð£¬ËüÓÐÒ»¸öÊôÐÔIUserService À´µ÷ÓÿØÖƲãµÄ·þÎñ£¬µ±
È»IUserService ±¾ÉíÒ²»áµ÷Óà IUserPepository Õâ¸öÔÚÊý¾Ý²ãµÄ·½·¨¡£Õâ¸öUserController ÓÃ
¿ØÖÆ·´×ªÀ´·ÃÎÊIUserService £¬Õâ¾ÍÊÇ˵Õâ¸öUserService Àà¾ÍÊÇÑ¡ÓÿØÖÆ·´×ªÀ´×¢Èë
UserController ʵÀý»¯IUserService;
public class UserController : Controller
{
    private readonly IUserService m_UserService;
    public UserController(IUserService userService)
    {
        m_UserService = userService;
    }
    public ActionResult Edit(int id)
    {
        return View(m_UserService.GetById(id));
    }
}
Õâ¾Í½ÐÈÝÆ÷×¢Èë,Èç¹ûÄã¾ÍÕâÑùд¶øÃ»ÓÐдÆäËüµÄÅäÖÃÎļþÄÇôÄ㽫µÃµ½ÈçϵĴíÎó£º
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where
it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined
for this object.  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ÆäʵĬÈϵģ¬Õâ¸öASP.NET MVC framework ÊÇÐèÒªÒ»¸ö¹¹Ô캯ÊýµÄ£¬Ò»ÖÖ·½·¨Êǹ¹ÔìÐÎʽÈçÏ£º
public UserController() : this(new UserService(new UserRepository()))
{
}
ÉÏÃæµÄ´úÂëÔËÐÐʱ¾ÍÊÇ


Ïà¹ØÎĵµ£º

¶ÔASP.NetÍøÕ¾¼Ü¹¹Éè¼ÆµÄ˼¿¼

ת£ºhttp://www.cnblogs.com/kumaws/articles/web_architecture.html
 
Ïà¶ÔÓÚ²»Í¬µÄÐèÇó£¬ÍøÕ¾µÄ´óС£¬¿ª·¢¸´ÔÓ¶È£¬³É±¾£¬ÍøÕ¾µÄ¼Ü¹¹Ò²·ÖÐí¶àÖÖ¡£
´ó¶àÊýСÐÍÍøÕ¾£¬ÐèÇó½ÏΪ¼òµ¥£¬°²È«ÐÔÒªÇ󲻸ߣ¬¿ª·¢Ê±¼ä¶Ì¡£Ò»°ãÕâÑùµÄÍøÕ¾£¬»¹»áÓÐÒ»¸öÓëÊý¾Ý¿âÖ®¼äµÄ½»»¥¡£ÓÃAsp.NetÖÐÌṩµÄ¿Ø¼þ£¬ÍêÈ«¿ÉÒÔÂú×㿪·¢µÄÒªÇó¡£Ò»° ......

ASP.NETÎļþÏÂÔØº¯ÊýʹÓÃ

 ASP.NETÎļþÏÂÔØº¯ÊýʹÓÃÊÇʲôÇé¿öÄØ£¿ÔÚÄãµÄPage_LoadÖÐÌí¼ÓÕâÑùµÄ´úÂë:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "Ä¿µÄÎļþÃû³Æ", @"Ô´Îļþ·¾¶", 1024000);
if (!success) Response.Write("ÏÂÔØÎļþ³ö´í£¡"); Page.Response.End();
ASP.NETÎļþÏÂÔØº¯Êý´úÂëΪ: ......

ASP.NET°²È«ÈÏÖ¤ Ò»

×÷Õߣºº®Óð·ã(cityhunter172)
Ðò
´úÂëд N ¾ÃÁË£¬×ÜÏëдµÃ±ðµÄ¡£Õâ²»£¬ÉÏͷ˵ÔÚÕûºÏÁ½¸öÏîÄ¿£¬×ö³Éµ¥Ò»µÇ¼£¨Single Sign On£©£¬Ò²ÓÐÈ˳ÆÖ®Îª“µ¥µãµÇ¼”¡£²éÔÄÏà¹ØÎĵµºó£¬ÖÕÓÚʵÏÖÁË£¬ÏÖÔÚ°ÑËüÄóöÀ´Óë´ó¼ÒÒ»Æð·ÖÏí¡£»òÐí´ó¼Ò»áÎÊ£º“ÕâÓë±êÌâ²»·ûѽ£¿”±ð¼±£¬ÔÚϱÊ֮ǰ£¬ÎÒÄÔ×ÓÀïÏëµ½ÁËÎÒ¸ÕʹÓà ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ