Reputation: 35
I'm trying to write Angular application with $routeProvider. I have .NET on backend that is serving htmls for my app (prepared with permissions and roles). On some action backend calls for RedirectToAction that means 302 HTTP to another url and that means my templateUrl inside router gets another html that it should with that route. I must catch this 302 HTTP somehow, and change route to another (or just use another controller).
Propably the best option is to rewrite backend and use API requests that would check if I need this redirection, but what to do when I can't change it?
I tried to use interceptor in $httpProvider but that response has HTTP 200 and just data of redirected site.
Upvotes: 0
Views: 251
Reputation: 126
I think it should not be the best way, but think about returning an http 200 and an object with a fild that tells the angular to redirect.
Some like:
{ location: "/my-new-location" }
And then, do the redirection in the application instead of doing in the backend!
Upvotes: 0