The content generated by the angluarjs2 project is merged into the asp.net mvc4 project and released.
Angular2 (NG2) project and. net mvc project are developed respectively. In the early stage, cross-origin access is used for parallel development. In the later stage, only the production version of The NG2 project needs to be merged into the. net project.
- . Net mvc Project Overview:
- Specific steps (only the operation content in. net mvc is described)
- Route content settings
// Prevent the user from refreshing the route pointing to the wrong routes. mapRoute (name: "ngdefault", url: "content/dist /{*.} ", defaults: new {controller =" Home ", action =" Index "}); // The Calling content routes in the original NG2 development framework. mapRoute (name: "MyRoute", url: "api/{controller}/{action}"); // normal page request for routes. mapRoute (name: "Default", url: "{controller}/{action}/{* pathInfo}", defaults: new {controller = "Home ", action = "Index "});
Page settings (The following is the page content corresponding to my Home controller Index)
@ {Layout = null ;}<! DOCTYPE html> @ * The following content should be set based on the content generated by your NG2 project. For details, refer to the content on the NG2 project boot page. * @ <Script type = "text/javascript" src = "~ /Content/dist/inline. js "> </script> <script type =" text/javascript "src = "~ /Content/dist/styles.41c78f28e60ca8b5fd69. bundle. js "> </script> <script type =" text/javascript "src = "~ /Content/dist/scripts. bc1943ee0f025606a729. bundle. js "> </script> <script type =" text/javascript "src = "~ /Content/dist/main.2ad5580a0f71e9dcee3e. bundle. js "> </script> </body>
NG2 project placement location
The published content is placed in the content directory. Therefore, you must set <base href = "/content/dist/"> in the head of the index page.
There are other better ways to operate, please kindly advise, and thank you again.