locked
MVC project to constantly update values from database RRS feed

  • Question

  • User-1138198114 posted

     have 10 desktop and 5 Laptops in my systems lab.

    I have written an asp.net MVC(C#) project to show the admin how many desktops and laptops are in use(there is a script which runs on each PC to update a database and my projects reads from the database using an API). The project also uses iframes, which runs as a slide show to show the laptops and desktops number.

    I have heard iframes are not the best choice. Is iframes best for the above scenario? If not how can I do this project?

    A different thought

    I have also heard about SignalR(new to it), but how would I go about doing this project in SignalR(if I want to redesign this project)?

    Saturday, February 2, 2019 4:07 PM

All replies

  • User475983607 posted

    I have heard iframes are not the best choice. Is iframes best for the above scenario? If not how can I do this project?

    An iFrame embeds an HTML document.  The embedded HTML can come from another web application.   It is not clear why you decided to use an iFrame or what problem it solves.

    A different thought

    I have also heard about SignalR(new to it), but how would I go about doing this project in SignalR(if I want to redesign this project)?

    SignalR takes advantage of the browser's Web Socket API  to persist a connection to the server.  SignalR is a good choice if your project requires real-time notifications.

    Saturday, February 2, 2019 4:20 PM
  • User-1138198114 posted

    @mgebhard,thanks for the quick reply.Yes my application requires real time notification. There is a display used by the admin to monitor the numbers.

    So how can I go ahead with SignalR?

    <div>I have an MVC(ASP.NET,C#) application to shows the number of laptops and desktops being used, which plays as a slide show(one iframe for Desktop another for Laptop) on one of the screens in our office.

    I have a controller called PCController, this controller passes to its View the child controller names (LapController and DeskController) which is used as the source of the iframes. 

    The iframe then calls the respective child controller to get the number of Laptops and Desktops from the database using the .net core API.<

    The slide show of the iframes are triggered by a button click every 60 sec by a code in parent View.

    The iframes are being refreshed every 30secs by a js in the child view.

    Saturday, February 2, 2019 4:38 PM
  • User475983607 posted

    You're describing a solution to a problem but not the actual problem.  What are you monitoring?  What is the purpose of monitoring laptops and desktops?  

    So how can I go ahead with SignalR?

    Start by going through the tutorials on this site and reading the documentation.

    https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-2.2&tabs=visual-studio

    Saturday, February 2, 2019 4:58 PM
  • User-1138198114 posted

    @mgebhard thank you for the link, I am monitoring the number of laptops and desktops that are in use and displaying it on a webpage using MVC5.

    I have 2 issues here

    1) Replace iframe and find a best alternative.

    2)Replace the jquery which triggers the refresh of the iframes to call the LapController and DeskController with SignalR.

    I am new to signalR,so do not have great idea about it.

    Saturday, February 2, 2019 9:57 PM
  • User475983607 posted

    newbiedev123

    @mgebhard thank you for the link, I am monitoring the number of laptops and desktops that are in use and displaying it on a webpage using MVC5.

    I'm having a hard time understanding the application.  As far as I can tell, you're monitoring a JavaScript/jQuery application running in the browser.  Usually, there's a purpose to the monitoring like controlling motors or reading sensors.  

    newbiedev123

    1) Replace iframe and find a best alternative.

    I have no idea what this means as you have not explained why you are using an iFrame but an alternative is simply updating the DOM directly.

    newbiedev123

    2)Replace the jquery which triggers the refresh of the iframes to call the LapController and DeskController with SignalR.

    I don't get this either.  If you went through the tutorials, SignalR is a JavaScript client that makes a persistent connection to a Hub.  The admin system would simply check how many connections are open at any given time at some frequency. 

    Saturday, February 2, 2019 10:25 PM
  • User1724605321 posted

    Hi newbiedev123,

    That seems you are requiring requirement :

    SignalR Database Update Notifications in ASP.NET MVC using SQL Dependency .

    Then query the application after get notification . If i misunderstand your requirement , please feel free to let me know .

    Best Regards,

    Nan Yu

    Monday, February 4, 2019 2:36 AM