I have a scenario where I am using .NET MVC to serve up an initial page 'index.cshtml' which then delivers all the Angular components required to run a single page app. For routing, I am using the excellent ui-router component by the Angular-UI team, and for the most part it works well.
My issue is with the very first page load. When browsing to the site, it doesn't go to the very first state/url. It just loads up my 'shell' with no content. My app config code looks like this:
app.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('home', {
url: "/home",
views: {
"content": {
templateUrl: "app/dashboard/dashboard.html",
controller: 'DashboardController'
},
"subNav": {}
},
});
If I click around the navigation (generated by ui-sref attributes) everything works fine. It's only the first page load. My first thought was that it was the .NET MVC routing that is somehow borking up the first request, so I think I've disabled it by changing the default route to the following:
routes.MapRoute(
name: "Default",
url: "{*url}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
But I can't be sure this has done what I wanted it to do. It certainly didn't fix my issue.
Any ideas?