0

I had been experiencing some weird auto redirection issues during which there is some unhandled exception caught in JavaScript context; it automatically redirects to http://localhost/# under my Windows 10 machine for no reason (normally it would be captured under Chrome Console Tab, but now it simply redirects to localhost).

A few thing that I had checked:

  1. Trying to reproduce this problem at Mozilla Firefox, the same result happened. So probably it's not browser issues.
  2. Restarted Visual Studio, restarted IIS. Not working.
  3. Checked IIS error redirection, nothing wrong (default and not set to anything special, in fact I doubt this is the part that could actually redirect the JavaScript level error).

I could not tell if it's problem from AngularJS routing issues, in fact I had not set / used the routing module too.

Armali
  • 18,255
  • 14
  • 57
  • 171
Richie86
  • 169
  • 1
  • 4

2 Answers2

0

check your application module for routeProvider or it may be arising due to the route mismatch.

eg:

 when('/', {
    title: 'Home',
    templateUrl: 'welcome/get_home_view',
    controller: 'HomeCtrl'
  }).

And give accurate path for any sub link(with all '/','#', as your application path define).

If you miss any thing ,you will bust to the base url(locachost/)

0

For redirection porpose you have to use routing model. include angular-route.js in your project. To do redicrection depending on user action you have to use $routeProvider. example of how routerprovider will work in angular app

var sampleApp = angular.module('TestApp', []);

sampleApp .config(['$routeProvider',
  function($routeProvider) {
    $routeProvider.
         when('/', {
        templateUrl: 'templates/welcome.html',
        controller: 'welcomeCtrl'
      }).
      when('/home', {
        templateUrl: 'templates/home.html',
        controller: 'homeCtrl'
      }).
      when('/dashborad', {
        templateUrl: 'templates/dashborad.html',
        controller: 'dashboradCtrl'
      }).
      otherwise({
        redirectTo: '/home'
      });
  }]);

here when none of the option match it will redirect to home page. hope it will help you.

surekha shelake
  • 246
  • 3
  • 7