I want to use MVC to load only a few pages, an index.cshtml and a few error views. The index page will contain only a <div ng-view></div>
and the app will only use one MVC controller. With my current set up everything seems to work fine until an Angular route attempts to a view, when that occurs I get either a 500 or a 404 depending on how I point to the html. Do I need to make an MVC ActionResult for every view I try to load? I was hoping to avoid that.
Here's an example MVC Controller.
public ActionResult Index(string code)
{
try
{
var model = new CodeContainer();
if (string.IsNullOrWhiteSpace(code))
return InvalidLink();
model = ValidateCode(code);
if (model.IsExpired)
{
return ExpiredView();
}
if (!model.IsValid || model.PatientID == -1)
{
return InvalidView();
}
else
{
return View();
}
}
catch (Exception ex)
{
// handle error
}
return InvalidView();
}
Here is how my Angular routing is set up using ngRoute.
careNotify.config(function ($routeProvider) {
$routeProvider.when('/', {
controller: 'MainController',
templateUrl: 'Views/splash.html'
}).when('/login', {
controller: 'loginController',
templateUrl: 'Views/Account/login.html'
})
});
Content of splash.html
<div class="home-splash">
<div class="home-overlay">
<div class="container">
<div class="logo-box">
<img src="images/cn-logo-splash.png">
</div>
</div>
<div class="main-content-footer">
<p>Powered by <img src="images/health-grid-logo-1.png"></p>
</div>
</div>
</div>
the index page will load into the RenderBody()
in the _layout.cshtml
as expected, yet when it tries to load the splash.html
view a 500 shows in the console. Switching to ../Views/splash.html
will cause a 404 instead.