Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I'm using angular-routing in my asp .net mvc project here getting warning like follows while passing parameters from mvc controller and displaying it on view where i want to pass user id from mvc. Can any one help me solve it and how to make it asynchronous?

"Synchronous XMLHttpRequest on the main thread is deprecated because 
of its detrimental effects to the end user's experience. For more help, 
check http://xhr.spec.whatwg.org/.
VM168:289WARNING: Tried to load angular more than once."

enter image description here

demoController.cs (demo controller page)

public ActionResult WithParams(int? type)
    {
        ViewBag.Type = type;
        return View();
    }

demo.cshtml (view)

    @{ 
      ViewBag.Title = "WithParams"; 
       }

<h2>WithParams</h2>

@if(ViewBag.Type==1)
{
    <p>You passed 1</p>
}
else
{
    <p>You Passed 2</p>
}

myapp.js (angular)

    angular.module('app',['ngRoute']).config(['$routeProvider',  function($routeProvider) {
    $routeProvider.
      when('/demo', {
        templateUrl: 'demo/demo',
        controller: 'demoCtrl'
      }). otherwise({
        redirectTo: '/'
      });
  }]).controller('dashCtrl' , function($scope){console.log("demo page")
}
share|improve this question
    
Links to localhost only work on your machine. Inspect the HTML in the browser and see whether there are multiple <script> elements trying to load angular. If there are, you need to work out where they're coming from. Most of the code you've put in the question seems to be irrelevant. – Damien_The_Unbeliever Oct 14 '15 at 7:07
    
Although you do add the code that shows the initialization of angularjs, this error is obviously to do with loading angular.js twice. You could have it in the @scripts section of the view and on the _layout.cshtml or maybe twice in the bundle.config. Hard to tell – gerdi Oct 14 '15 at 10:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.