In my asp.net 4.0 eCommerce web application, a logged-in customer can click on anchors such as "Orders in the past 6 months" or "Orders in the past year" to view his past orders. When such anchors are clicked, I make a $.ajax call to my asmx web service method to retrieve a list of past orders and display them, like below:
$.ajax({
type: "POST",
url: "/webservices/OrderServices.asmx/GetOrderList",
data: theParamter,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){
displayOrders(data);
},
error: function(errMsg) {
alert(errMsg);
}
});
The web service method in c# is very simple, just a web method to get a list of orders for the specified past duration.
theParameter is obtained before the ajax call, which is just a parameter indicating if the customer wants to view the orders of the past 6 months or past year.
Everything works perfectly on my dev environment using IIS Express. But on production, when user clicks on either of the anchors, the browser pops up a small diablog box, asking the user to enter user name and password.
What's causing this? The web service (asmx) isn't aware that the request is sent from an authenticated customer? How to prevent the browser from displaying the authentication popup? Thank you!