The stack you're suggesting is perfectly good to use.
My team has built an application in the past where we had 2 razor pages, the one was basically the external app (by external I mean non-logged in user) which was quite light weight and only handled signup, then the other acted as an internal shell for the rest of the app (once logged in).
- The .NET bundling allowed us to do some cool things like only delivering certain scripts to certain razor pages. EG a non-logged in user didn't need to be served the whole internal app.
- Using this method also allows you to utilize the built in ASP.NET auth framework.
I recently stumbled across a really cool bootstrap project that can help you construct a boilerplate app. My suggestion is just download this, and have a look through the boilerplate app to give you more clarity on its usage. (Then it's up to you if you want to use it or not, but it'll give you more clarity on solution construction)
Thus your final app would have one (or 2) MVC controller(s) that deliver your shell pages, and all other calls would be done via WebAPI endpoints. See rough example below:
..\Controllers\RootController.cs
public class RootController : Controller
{
// we only utilize one server side rendered page to deliver out initial
// payloads; scripts; css; etc.
public ActionResult Index()
{
// using partial view allows you to get rid of the _layout.cshtml page
return PartialView();
}
}
..\Views\Root\Index.cshtml
<html ng-app="MyAngularApp">
<head>
@Styles.Render("~/content/css")
@Scripts.Render("~/bundles/js")
@Scripts.Render("~/bundles/app")
</head>
<body>
<div class="container">
<div ng-view></div>
</div>
</body>
</html>
..\WebAPI\SomethingController.cs
public class SomethingController : ApiController
{
private readonly IRepository _repo;
public SomethingController(IRepository repo)
{
_repo = repo;
}
// GET: api/Somethings
public IQueryable<Something> GetSomethings()
{
return _repo.GetAll();
}
}
Tip:
The easiest way I've found to construct projects like this is to use the Visual Studio's New Project Wizard. Select Web Project -> MVC
, Make sure to Select WebAPI
. This will ensure that App_Start has all the required routes & configs pre-generated.
