I've noticed a strange behaviour on Microsoft Edge and an ajax request with jQuery. In a page I have this code
$("#btnSend").click(function () {
$("#sending").show();
$.ajax({
type: 'GET',
url: '/Report/SaveQuoteOnFile?quote=18',
crossDomain: true,
success: function (msg) {
if (msg == 'True') {
alert('Email sent to the client');
}
$("#sending").hide();
},
error: function (request, status, error) {
$("#sending").hide();
}
});
});
The WebApi is build in C# and the code is something like
public bool SaveQuoteOnFile(int quote)
{
bool rtn = false;
Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST");
Response.Headers.Add("Access-Control-Allow-Headers", "accept, authority");
Response.Headers.Add("Access-Control-Allow-Credentials", "true");
// code to send an email
// if the email is sent rtn = true
...
return rtn;
}
When I open the page with Chrome and click on the button btnSend, Chrome calls the WebAPI, the email is sent, the result is true and I show a message. If I insert a breakpoint in the WebApi, I can follow the code step by step. I'm assuming is always the same.
Now I open the same open with Microsoft Edge and click on the button btnSend, it seems calling the WebApi, the result is true and I show a message but the email isn't sent. The same breakpoint doesn't fire.
The first thing I thought was the WebApi code is wrong. Obviously. I tried it with Mozilla and Safari but it's working fine.
Idea. I cleaned the cache and other stuff on Microsoft Edge. I click on the button and now everything is working fine! Then I'm so happy and I show my job to my boss on my desktop. On Microsoft Edge I click again on the button and nothing happened. It's working fine with other browsers. I clean again the cache and other stuff on Microsoft Edge and... it's working fine again...
Ok, the problem is the cache (???) but how I can solve in general this problem? Thank you in advance for any suggestions.