I'm having a problem with Angular JS on IIS 8.x with MVC. My application index page with virtual directory is like so:
https://myapp.xyz/VirtualDirectory/
That page loads the angular app. My angular routes are set up as:
$routeProvider
.when('/', {
templateUrl: 'Content/Partials/Home/Index.html'
})
.when('/Error', {
templateUrl: 'Content/Partials/Shared/Error.html'
})
.otherwise({
redirectTo: '/Error'
});
So, if I access the first link, my URL looks like:
https://myapp.xyz/VirtualDirectory/#/
This works perfectly and resolves my partials fine. Angular requests the partials with the virtual directory in it so I see an HTTP request to:
https://myapp.xyz/VirtualDirectory/Content/Partials/Home/Index.html
However, if I access without a trailing slash like:
https://myapp.xyz/VirtualDirectory
Angular routes to:
https://myapp.xyz/VirtualDirectory#/
Once this happens, none of my routes work (they do not respect the virtual directory). They route as:
https://myapp.xyz/Content/Partials/Home/Index.html
This breaks all of my routes and templates defined in my directives. Any suggestions on how to fix this issue?
try to add this in you head tag.
<html>
<head>
<base href="/VirtualDirectory/">
</head>
<body>
...
</body>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With