1

I am creating one Web Application in C# MVC and i want one features for play beep at every time interval which i have defined in variable.

I'm using setInterval() function of javascript in layout page but it is called on every page load and inverval is reseting.

I have tried some solution but still can't get any solution.

hawk
  • 5,409
  • 2
  • 23
  • 29
Bharat
  • 93
  • 11
  • You can't do this without hacks, you need different kind of technologies, e.g. SPA (Single Page Application). C# MVC is not good fot this. – hawk Feb 24 '17 at 06:39
  • @hawk, with due respect, that's quite an opinionated comment, when there is enough documentation on how to build SPAs using ASP.NET MVC and C#. For instance: https://learn.microsoft.com/en-us/aspnet/single-page-application/overview/. – sudheeshix Feb 24 '17 at 06:56
  • thanks for reply.i have already created on POS system in C# MVC and in same system I want to create above feature. – Bharat Feb 24 '17 at 07:04
  • 1
    @sudheeshix true, i think you misunderstood me. I said C# MVC can't be used as SPA alone, of course you need something link React, Angular, Knockout, Ember etc. For backend part I think C# WebAPI is more than enough. But this is another story, Regards. – hawk Feb 24 '17 at 12:20
  • @hawk, thanks for clarifying. – sudheeshix Feb 24 '17 at 19:46

1 Answers1

0

You can avoid page reloads if you have subsequent requests (after the initial page load) return partial pages (html) or data (typically json). This can then be rendered on the page quite simply using AJAX, or if you feel inclined to, by using a JavaScript framework such as Angular to build a Single Page Application.

With ASP.NET MVC, you can explore sending back JsonResult from the controller actions instead of ViewResult.

sudheeshix
  • 1,541
  • 2
  • 17
  • 28