Intregrating an angular site into an asp.net MVC site

Mark 21 Reputation points
2021-10-26T08:21:58.213+00:00

I have an existing asp.net mvc application made up of various projects and want to incorporate some angular code into one of my views (within the web project).

I have a standalone angular website and am not sure how to get the code that appears in the Index.html page of the angular website into my asp.net view.

I tried firstly adding the angular site to my solution then altering the selector and templateUrl in the app.component.ts file (to point to my cshtml file which included the selector markup) but with no success.

Would appreciate any help on this...

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,254 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Peter Davie 0 Reputation points
    2023-05-20T01:05:09.6033333+00:00

    I recently had the same issue, and came across your post. I considered that given the index.html file in an Angular application is generated, trying to incorporate the content into a cshtml file would eventually break in time, even if there was some initial success. Indeed, with Angular 15, the generated index.html contains module references for the generated JavaScript files, which I could not see any way to achieve in ASP.NET. My solution was to copy the Angular generated content and then redirect the ASP. NET request to deliver the index.html file. I am not sure if this is appropriate for your circumstances.

    0 comments No comments