ÔÚ¿ª·¢µÄ¹ý³ÌÖУ¬ÎÒÃÇ»áÓõ½AngularCLIÃüÁîÖÐµÄ ng serve ÃüÁîÀ´ÆôÓÃAngularµÄ¼à¿Ø·þÎñģʽ¡£Ëû»á¼à¿ØAngularµÄÔ´Âë±ä»¯£¬µ±Ô´Âë±»¸Ä±äʱ£¬×Ô¶¯ÖØбàÒëAngular³ÌÐò²¢±àÒëTypeScript´úÂ롣ĬÈÏÇé¿öÏÂng serveÌṩµÄÊÇlocalhost:4200µØÖ·¡£
²¢ÇÒAngularĬÈϽÓÊÜRequestµÄµØַΪlocalhost:4200/api£¬ÕâÓëÎÒÃÇAsp.Net CoreĬÈϵÄlocalhost:5000²»Ò»Ñù¡£
ËùÒÔÎÒÃÇҪͨ¹ýÅäÖÃproxyÀ´½â¾öÕâ¸öÎÊÌâ¡£
Ê×ÏÈÔÚÏîÄ¿¸ùĿ¼ÖÐÌí¼ÓÒ»¸öjsonÎļþ£¬È¡Ãû×Ö½Ðproxy.config.json
ΪÕâ¸öÎļþÌí¼ÓÈçÏÂÅäÖôúÂë
{ : { : , : false } }
2. ÆôÓÃAsp.Net Core×Ô¶¯±àÒëÈç¹ûAngularÄܹ»×Ô¶¯½øÐиü¸ÄÖرàÒëÔËÐУ¬²¢ÇÒAsp.Net CoreÒ²ÄÜÓüà¿Ø¸ü¸Ä×Ô¶¯ÖرàÒ룬ÄǾø¶ÔÊÇÎÒÏëÒªµÄ¡£
ÆôÓÃAsp.Net Core×Ô¶¯ÖرàÒ룬ÐèÒªÐÞ¸Ä.csprojÎļþ£¬Ìí¼ÓÒ»¸öDotNetCLI¹¤¾ß°ü¡£´úÂëÈçÏ£º
±£´æÎļþºó£¬VS»á×Ô¶¯»¹Ô°²×°Õâ¸ö°ü¡£Èç¹ûûÓÐ×Ô¶¯»¹Ô£¬ÇëʹÓÃDotNetCLIÃüÃû»¹Ô°ü£º
dotnet restore
3. ÒÔ¼à¿ØģʽͬʱÔËÐÐAngularºÍAsp.Net CoreʹÓÃPowerShell»òCMDÃüÁîÐй¤¾ß£¬ÔËÐÐÈçÏÂÃüÁîÒÔ¼à¿ØģʽÆôÓÃAsp.Net Core·þÎñÆ÷
dotnet watch run
´ò¿ªÁíÒ»¸öPowerShell»òCMDÃüÁîÐй¤¾ß£¬ÒÔ¼à¿ØģʽÅäÖÃÎļþÔËÐÐAngular
ng serve --proxy-config proxy.config.json
ÏÖÔÚÈÃÎÒÃÇ´ò¿ªä¯ÀÀÆ÷£¬·ÃÎÊ:4200
´ò¿ªValuesContoller£¬ÈÃÎÒÃǸü¸ÄһЩ¶«Î÷£º
´ò¿ªClientApp/app/app.component.htmlÎļþ£¬¸ü¸ÄһЩ¶«Î÷£º
±£´æÉÏÃæÁ½²½µÄ¸ü¸Äºó£¬»Øµ½ä¯ÀÀÆ÷£¬Äã»á¾ªÆæµÄ·¢ÏÖ£¬Asp.Net CoreºÍAngularµÄ´úÂë±ä¸üÒѾÉúЧÁË
OK ,ÖÁ´Ë£¬Ê¹ÓÃÔÚVisual Studio 2017ÖÐʹÓÃAsp.Net Core¹¹½¨Angular4Ó¦ÓóÌÐò׫дÍê±Ï¡£
Ï£Íû±¾ÎĶÔÄãÓÐËù°ïÖú
תÔØÇëÖøÃû³ö´¦£º
Èç¹ûÓÐÄÄλ´óÉñÖªµÀ¸üºÃµÄ²¢ÐÐÔËÐнâ¾ö·½°¸£¬ÇëΪÎÒÁôÑÔ»òÁªÏµÎÒ£¬ÔÙ´ÎÏÈÐÐл¹ý~
×îºó¸½Éϱ¾ÏîÄ¿µÄÔ´Â룺¡¡https://github.com/smallprogram/AspNetCoreWithAngular4¡¡£¬ÐèÒªÊÖ¹¤»¹ÔNPMŶ¡«
ÇëÇ󲩿ÍÔ°µÄ³¬¹Ü¸ø¼Ó¸ö¾«~
¡¡