0

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")
}
2
  • 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. Commented Oct 14, 2015 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 Commented Oct 14, 2015 at 10:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.