首页 > 技术文章 > One difference between AngularJS' $location and window.location

xixifusigao 2014-09-03 16:47 原文

Recenently, I encountered a problem. 

Client side code is:

$http({
url: "/api/runtimelicense"
, method: "GET"
})
.success(function (data) {
window.location('#/search');
})
.error(function () {
});

 

Server side code is:

DbContext_context = GetContext(); // Just get dbcontexnt.

_context.MyDBSet.Where(s => s.ID == myID).ToList(); // When this request is from IE,it always throw exception with message "The connection was not closed. The connection's current state is open."; but if this request is from Chrome, all are ok.

 

At beginning, I felt very strange, as I know, browser should not impact server side by the same http request. I open Fiddler to see, there is an AngularJs digest error in IE, this error causes another request, it means there are two same http request to submit. I googled this question, but got nothing. I just repalce "window.location('#/search');" with "$location.path('/search');" , this issue is solved. Now, I still cannot know the details clearly. So, remain 2 questions:

1) Why does IE Angular digest exception?

2) Why does exception can cause another request?

 

推荐阅读