How to work when internet connection down? - asp.net

How to work when internet connection down in a asp.net application ?
Means Users are working on application and suddenly internet connection down then user should still be able to add/edit/ delete operation on data, but when internet connection is up then
all changes should be done at server. Is that possible, Is there any example available to achieve this?
Thanks.

HTML5 has some offline capabilities. http://www.html5rocks.com/en/features/offline
But do you really have a business case for this? It will get complicated when you need to try and update stale data etc.

This requires use of JavaScript to store local data http://code.msdn.microsoft.com/Working-with-HTML5-local-b0cbe2ef and it needs to check whether the server can be reached before doing a proper postback, or more likely just use AJAX to communicate between the JavaScript application and the server.
There are several applications like this such as Google Mail, and such solutions are more JavaScript based than ASP.NET and you need to avoid relying on the web forms mechanisms and use .NET for building the initial page, dealing with AJAX requests and managing the application data and persistence. See How to write an offline version of an AJAX/ASP.NET web application

Related

How to Design a Database Monitoring Application

I'm designing a database monitoring application. Basically, the database will be hosted in the cloud and record-level access to it will be provided via custom written clients for Windows, iOS, Android etc. The basic scenario can be implemented via web services (ASP.NET WebAPI). For example, the client will make a GET request to the web service to fetch an entry. However, one of the requirements is that the client should automatically refresh UI, in case another user (using a different instance of the client) updates the same record AND the auto-refresh needs to happen under a second of record being updated - so that info is always up-to-date.
Polling could be an option but the active clients could number in hundreds of thousands, so I'm looking for a more robust and lightweight (on server) solution. I'm versed in .NET and C++/Windows and I could roll-out a complete solution in C++/Windows using IO Completion Ports but feel like that would be an overkill and require too much development time. Looked into ASP.NET WebAPI but not being able to send out notifications is its limitation. Are there any frameworks/technologies in Windows ecosystem that can address this scenario and scale easily as well? Any good options outside windows ecosystem e.g. node.js?
You did not specify a database that can be used so if you are able to use MSSQL Server, you may want to lookup SQL Dependency feature. IF configured and used correctly, you will be notified if there are any changes in the database.
Pair this with SignalR or any real-time front-end framework of your choice and you'll have real-time updates as you described.
One catch though is that SQL Dependency only tells you that something changed. Whatever it was, you are responsible to track which record it is. That adds an extra layer of difficulty but is much better than polling.
You may want to search through the sqldependency tag here at SO to go from here to where you want your app to be.
My first thought was to have webservice call that "stays alive" or the html5 protocol called WebSockets. You can maintain lots of connections but hundreds of thousands seems too large. Therefore the webservice needs to have a way to contact the clients with stateless connections. So build a webservice in the client that the webservices server can communicate with. This may be an issue due to firewall issues.
If firewalls are not an issue then you may not need a webservice in the client. You can instead implement a server socket on the client.
For mobile clients, if implementing a server socket is not a possibility then use push notifications. Perhaps look at https://stackoverflow.com/a/6676586/4350148 for a similar issue.
Finally you may want to consider a content delivery network.
One last point is that hopefully you don't need to contact all 100000 users within 1 second. I am assuming that with so many users you have quite a few servers.
Take a look at Maximum concurrent Socket.IO connections regarding the max number of open websocket connections;
Also consider whether your estimate of on the order of 100000 of simultaneous users is accurate.

Sessions in Azure: client side sessions possible?

As you already know, due to the missing sticky session functionality, session information in Azure web roles have to be stored in places like SQL Azure or the Appfabric Cache when using multiple role instances. I know this is the best approach - but apart from that, would it also be possible to store sessions on client side like described here on msdn? I can imagine using cookies would be easy, but what about the other solutions mentioned there? I'm not going to do this, I'm just interested in how reliable such a solution would be.
Yes, these options are all available.
As far as the client side is concerned there's no discernible difference between an ASP.NET site running on Azure from any other kind of ASP.NET site.
If you know you are working with clients with reasonably recent browsers (such as mobile devices) you may find HTML 5 storage is also an option. See here: http://dev.w3.org/html5/webstorage/

Client queue filled by server queue over the internet with ASP.Net and WPF client

I am trying to find the right approach for an application, that I am trying to develop.
Situation:
ASP.Net Website. User can make a request on a page. The request must result in an item in a qeue on the server. The qeue targeted is specific for each customer.
WPF client at customer site. The WPF client has a local qeue. The qeue gets filled by either polling the qeue on the webserver or getting a message from the web server. The WPF client uses the qeue to display items as specified in the qeue.
Each WPF client user has it's own account and can only access the qeue that is meant for him.
I dont have any constraints yet as to which solution to use, as long as it is .Net technology and the customer only requires my deployment package and the .Net framework. I can't hassle customers to install something like MSMQ.
I think a database on the webserver containing all the requests could do the trick, but I am wondering if there are any other slick methods that could be better.
Cheers, Momoski
You are going to want to have your clients pull from the web server/service and not try to push updates out to your clients. There is way to much complexity for a push solution unless you have complete control over all systems involved (i.e. network, firewalls, etc...).

Best architecture for an emergency alert system

I'm developing a software system which receives information (which is saved to a database) and when any information is received (new insert in a specific table) an alert should be seen in the screen in the information center, so proper action can be taken.
I'm writing an application with ASPNET MVC, SQL Server 2008 Express, SQL Agent free for that version of SQL Server, Entity Framework 4, Visual Studio 2010, etc.
Right now, I've set the database and a SQL job that monitors the table each minute, if there is a new records an email is sent to same addresses. My problem is...What then? Which would be the best architecture to follow?
A couple of option I thought about are:
1) In the job connect to a web service and that web service an the web service can open a popup
2) The web page could be pooling the database table to know if there are new records
Is there any way to make push to the web page instead of the page pooling the database server?
I know maybe windows application would fit better here, but right now I must stick with ASPNET MVC as I already started and don't want to create another application.
Thanks! Daniel
Is there any way to make push to the web page instead of the page pooling the database server?
HTML5 WebSockets. Draft, pretty new, specification is still subject to change, to all browsers implement it. You will need a WebSocket Server. If you go that route make sure you read this guy's blog. He is behind Laharsub which is a must try server.
I'm pretty sure you are able to use Silverlight to push data down to the client. Here is a pretty good overview that I read a while back. HTML5 might be a better way to go. But with such limited support it's almost not worth it at this point. Granted the Silverlight application might be out of reach to, but it's still a possibility.
I would suggest that you look into (complex) event processing, or stream processing -- at least to get the feeling for architecture of these systems.
The idea is to capture a stream of events before they reach database, route them (process) within the event processor and put them in the DB from there -- treating the DB as only one of event destinations (subscribers).
Take a look at Streambase, ruleCore, and many others.
These were all developed for the type of scenario you described.
Try to see the problem from the other angle. Develop a web client that reads the database every minute and compare to last pull ...

asp.net sending data

How do you send data from an ASP.NET web application to a windows form application?? How do you establish the connection? I looked up webrequest/webresponse/post but i think thats only if you want to communicate between 2 asp.net web applications.
You might use a socket.
It would help if you're more specific about exactly what you're trying to accomplish. Do you need live communication, or would connecting to a shared database do what you need? Is the web application on the same computer as the server or a different one from the forms application?
Update:
If you're trying to pass messages to the Windows Form without using or implementing any sort of protocol, you might look into how to use LISTEN/NOTIFY on PostgreSQL. You could then just add data to a table, then have the forms application consume the data. This would have the added benefit that your forms app wouldn't have to miss any data if it was not on.
My opinion to you is to implement a webservice. I made a project for mobile devices using webservices, the mobiles had an application made in winforms that call a webmethod that made an action which was registered in the system. A web page showed the data and the events of every mobile device.
If you need an explantation of webservices you can go here.
The strategy in your case would be to implement the Observer Pattern or to raise an event to make the application or winform to be noticed about a change or action in the web page.

Resources