I am working on an asp.net application. "Online Examination".
my application will uses the concept of session to maintain the state of user who is giving the exam. , since in case browser shut down, system crash i do not want my user should start from the 1st question.
Infact, i want my user should start from where he left. Now i am not able to think on this.
How to test this. Is there any easy way so that i can simply test my concept.
CASE1: USER WANT TO QUIT FROM EXAM. SO HE/SHE CAN INTENTIONALLY CLOSE THE BROWSER.
CASE2: BY MISTAKE USER CLOSE THE BROWSER, SO WHEN HE RETURN BACK HE/SHE WILL START THE EXAM FROM WHERE HE/SHE LEFT.
he just have to enter the url> enter his exam id> continue the exam.
Plssss help me in this respect. give me some idea how to apply session management.
You cannot distinguish between Case1 and Case2. Typically in these scenarios there is a button on the web page like Logout or Finish that would mark the exam as completed. Simply closing the browser would mean that the exam is still in progress.
Also note that you cannot use standard Session state management - that lasts only while the browser is open. You have to store the exam progress data in a database based on the user's ID.
Use application variables so that we can easily remove this when the user suddenly closes the browser or tab.
Related
I would like to ask, if it is a good idea to use SinglR just for knowing if the current user now online or not?
For example I have an small website with log in system, and some where on the side i would like to show the logged in members.
Is this a good idea to use signalr for that?
And if it the case should I then on each page start the connection with hub? (In this case when user navigates on the pages, will be the ReConnected method called on hub, or OnDisconnected and OnConnected)?
I'm just starting with signalr, so curious what ppl think.
You could use SignalR though there might be better methods to do this. So when a user logs in, logs out or becomes inactive - you would have some sort of message being sent from the client to the server that indicates the change in status. You can store that information in a temporary database and whenever a value in the database changes you can use SignalR to relay that information to all the connected clients.
Signalr will get reconnected when the user moves from one page to another page. Whenever a user logs into a website the user security details will be persisted in a cookie assuming you are using Cookiebase authentication. So till the user logs out or session timesout the cookie will be active. So there is no real need for Signalr here.
I have been investigating the same thing. From my research, I would say that you COULD do this, but I'm on the fence of whether it's the best way to go about it. I would expect a LOT of disconnecting, connecting and reconnecting. If you're persisting this data in a database, you should anticipate a lot of database traffic. if you're only on a single server though, you could just persist this in memory.
Something to also note is that the ConnectionId changes with each page refresh. At first, I thought that was dumb because I wanted the connection id to be consistent so i could keep a handle on a user with it. However, if you open a link in a new tab and then close one of them, you have to still keep the other connection in storage. If the id was the same you would remove it on disconnect even though the other tab was open, so your user would incorrectly be marked as offline.
However, the other issue that i'm thinking about is that if you're just browsing around the site in a single tab, you will disconnect for a split second between each page load. So you might run into connection consistency issues with that.
I'd say online presence with signalr is more common to be used for a chat room or game lobby. So I'd say this is possible, but whether it's a good solution -- i'm unsure.
I am developing a matrimonial web application in asp.net. In that I want to display number of users in online (logged in).
I am planning to maintain a "login-status table" in dB. And will maintain the table every time the user have logged in and out. But there is problem if the user have closed the browser directly without logging out.
Is there any other easy way to achieve this. Pleas provide sample code.
And I want to know how can I update the table that if the user click the browser's close button.
I recently implemented something similar. The challenge I had is what defines "online". What if the user walks away from the computer, closes the browser, network is disconnected?
In the end I went with online means visited a page in the last 15 minutes. It avoids the issues with trying to detect when they walk away from the browser, or close it.
I did consider binding to the browsers onclose event and hitting a /user/closed/browser url. I have used that before in a call center website to unlock the call. But really the 15 minute rule was "good enough".
I coded it by keeping an in memory dictionary that I persisted to db every 5 minutes. Sorry I have no code to provide.
We currently have workflow app built with infopath, sharepoint and bitztalk.
Basically, an empployee fills out a form, saves it and clicks "Forward to Manager"
His/her receives an email notification that a form is waiting in his/her queue to be completed.
Manager completes and forwards to next higher up.
The process continues until the final manager sign off and the process is now considered complete.
The cycle can begin again with new form.
The company hired a contractor to do this and is nowwhere to be found.
Unfortunately, we have no one inhouse with the knowledge to maintain this.
I have been asked to try and find out from you experts if it is possible to do this in asp.net.
If yes, can you please provide me with some links to get me started?
Many thanks in advance
I want to execute a action on the event of browser crash in asp.net. I want to destroy the item added in the cart and revert back to the original state of the application and database if the browser crashes.
How can I do this?
Sadly, not possible, due to several factors.
1) the net is stateless, that is to say that the web server has no idea about the web browser, other than that it requested something. After it's serviced the request, it has no way of communicating with the browser.
2) the browser has the same issue. Once it's asked the server for the content and got it, that's it. If the user closes their browser, or lets their session time out, or if the browser crashes, the server doesn't know about it, and the browser doesn't tell it.
3) if the browser crashes, it's crashed, so it can't send any information anywhere, on account of the fact that it isn't working any more.
You can hook into the session_end event, which will fire when a user's session ends (a session ends when the user hasn't asked for anything for a certain period of time, 20 minutes is the default for this), however there's no way to tell WHY the session ended. the users browser may have crashed, they may have closed their browser, or they may have got bored and gone to another site.
Normally I wouldn't update the application state until after a user checks out, so the basket would be the only thing I'd need to delete. To do that I set a datetime column on my cart table, and update it every time the cart is updated. I then run a scheduled task on the database every day that deletes all baskets that are older than the amount of time I keep the baskets for.
Here's the question scenario:
Suppose you have a multiple-page ASP.NET web site with the following
requirements:
User-specific data for the currently logged in user is loaded and is required on each individual page of the application during a user's session.
The application itself only allows a certain number of users to be logged in at one time.
The next time a specific user logs in, the user should be returned to the last page visited.
Given this information, briefly describe how you would use ASP.NET to manage the state of the application to meet these needs?
Here's my thoughts and reasons. Please provide yours.
User-specific data for the currently
logged in user is loaded and is
required on each individual page of
the application during a user's
session.
This is suggesting to me that the interviewer is looking to see if I would suggest using Master pages as a way to provide a common approach to displaying the same thing on every page.
The application itself only allows a
certain number of users to be logged
in at one time.
Could the sought response be that, because scaling isn't an issue due to the limited number of users, that it is OK to put this information in the Session object for performance reasons or is this a trap and some of approach is better?
The next time a specific user logs in,
the user should be returned to the
last page visited
A cookie seems the best approach to track the last page access, since this doesn't seem to be critical information.
Please tell me how you would handle these question if you wanted to make the best impression
Feel free to provide input or comment an any line item.
Thanks!
As far as (3) is concerned, consider a shared PC. User A logs into a website using their site based user name/password. Does a whole load of work and shuts down the browser. USer B then comes along and on the same PC logs into the same site using their details. However, they will get the cookie from User A and be redirected to the last page they saw. This happens because Cookies are tied to the browser / OS user, where as you are potentially applying the site security separately in the application.
In this situation you would either need to put the user name into the cookie (encrypted) or use a server side method to store the location
Here are my thoughts:
They might be looking for Master Pages, but my first thought here was whether you're going to cache this user data, so you're not making a database query every time they hit a new page. To really impress them, you might mention partial caching techniques so that the repetitive portions of the page don't even need to be re-rendered with each page load.
I think you're right: they're helping you to conclude that the session state is an appropriate place to cache the user data. Just be sure you ask the appropriate questions, like "How many users?", and "How much data per user?"
The cached data could be used to keep track of the last-requested page, and when the user's session expires, you could save this data into a database table to be retrieved next time they log in.
That third item is awfully tricky. What if the user was last looking at an object that has since been deleted? What would be the intended behavior if a user logged in from one computer, did some work, and then logged in simultaneously from another computer or browser? I'd be sure to ask these kinds of questions, not least to show that I understand the implications of a requirement like this. If their responses lead you to believe that they're looking for a simple solution, go with the simple solution. Otherwise, tweak your response to be only as complicated as necessary.
Just a small thought.. If the system are running in a "Farmed" environment the Session data can be cleared and need to be handled some way.
http://www.beansoftware.com/ASP.NET-Tutorials/Store-Session-State-Server.aspx