none
How to call views from a host application using modular approach? RRS feed

  • Question

  • Hi, I am building a modular application. The idea here is to make a Host asp.core web app with multiple Modules(web apps) linked to it. The modules will be Angular/React SPAs. 

    I want my Index view of Host to have links to my Modules's views. I read few articles that suggest me to register my modules(assembly) in host app using AddApplicationPart() which is fine. But how do I proceed after that? How should I call the view or link them in my Index view of Host web app?


    ms forum help

    Monday, June 17, 2019 2:39 PM

All replies

  • Hi Aniket,

    Welcome to the MSDN forum.

    As far as I know, the application parts in ASP.NET Core is used to re-use Controllers, Views and Tag-helpers. Since I don’t know how to you build your angular/react application module.

    If you embedded the Angular or React application into MVC view, you could still use application parts to achieve your requirement.

    If you create it in a different application, I suggest you could try to use iframe or other ways to embedded the page into your application.

    If you create it in same application but not embedded the SPA into the MVC view, I suggest you could try to use partial view by using Html.Raw method.

    @Html.Raw(File.ReadAllText(Server.MapPath("~/dist/index.html")))

    The index.html will bring in the compiled and bundled html, JS and CSS files. Make sure you remove the header and body tag from the src/index.html if any.

    Besides, since this case is talking about the asp.net core application, I suggest you could post this issue on asp.net core forum: https://forums.asp.net/1255.aspx/1?ASP+NET+Core

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, June 18, 2019 7:23 AM