DanielD DanielD - 5 months ago 16
Ajax Question

Rendering ViewComponent with ajax don't work in Edge/IE11

I have a simple ViewComponent works correctly in the browser chrome and Firefox but do not work in a browser Edge \ IE 11.

The component shows the time (just for example).

Chrome and firefox time is displayed.

Edge Browser \ IE 11, time is displayed only the first time the page is up and remains so, time is "frozen".


When I open the browser Edge development tools as well as in IE 11, the component starts to work properly and current time is displayed (just like other browsers)

And when I close the F12 development tools, component stops working (time "frozen").

And it repeated - F12 open the component works, F12 Close component stops working.

Am I missing something here ?

Attaching the simple code of the process
Thank you


public IActionResult GetTime()
return ViewComponent("GetTime");
//// var time = DateTime.Now.ToString("h:mm:ss");
//// return Content($"The current time is {time}");


public class GetTimeViewComponent : ViewComponent

public IViewComponentResult Invoke()

var model = new string[]
"Hello", DateTime.Now.ToString("h:mm:ss") , "the", "view", "component."
return View("Default", model);




@model string[]
@foreach (var item in Model)
<li class="text-danger">@item</li>


<div id="myComponentContainer">@await Component.InvokeAsync("GetTime") </div>

**Js / Ajax**

$(function () {

var refreshComponent = function () {
$.get("Home/GetTime", function (data) {
$(function () { window.setInterval(refreshComponent, 1000); });



Try to set cache false in ajaxSetup

$.ajaxSetup({ cache: false });

Or use

$.ajax({ cache: false, //other options... });