currently if I want to work with asp.net core and angular I do the following:
- create a client app with angular cli
- create an asp.net core mvc app
- connect the two with Microsoft.AspNetCore.SpaServices.Extensions (spa strategy = proxy)
- modify the
Index.htmlof the mvc app like this:
@section scripts {
<script src="runtime.js"></script>
<script src="polyfills.js"></script>
<script src="styles.js"></script>
<script src="vendor.js"></script>
<script src="main.js"></script>
}
<app-root></app-root>
- modify the
_Layout.htmllike this:
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>App</title>
</head>
<body>
<h2 class="bg-dark text-white p-2">App</h2>
@RenderBody()
@RenderSection("Scripts", required: false)
</body>
</html>
Then I start the angular server and run the mvc app too. As you can see, in this case I use the Index.html of the mvc app and projects the angular content into it. I will use the asp.net core app only for serving Rest api request, so nothing with views, etc.
I have three questions on it:
- Is the above described a convenient way to work with angular, where the asp.net core part is acting only as a Rest api server? If not, then what is it?
- Could I use the
index.htmlof the angular client app too? I mean, the asp.net core part would be really only serving the api requests and the entry point of the app would be theindex.htmlof the angular client app?
Thank you for your answer/comments.