Navigation

Search

Categories

On this page

Asp.Net Session Timeout control
Fixing Gaps in Corners while using Ajax control toolkit RoundedCorners Extender
I am on Twitter
Cool Silverlight app
Get free Visual Studio 2008 and .NET Framework Training kit
Registration for VS2008, Sql Server 2008 and Windows Server 2008 launch event now open
Debugging Dot Net Source Code in VS2008
Concatenating rows in a table into a single string using sql
Free e-books from Microsoft Press on VS2008 technologies

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 22
This Year: 12
This Month: 0
This Week: 0
Comments: 7

Sign In

 Friday, August 29, 2008
Friday, August 29, 2008 3:32:43 PM (Mountain Standard Time, UTC-07:00) ( )

As web application developers, we depend on the Session to store data pertaining to the user. It's a common scenario that the user might take a half an hour break to take a phone call or a meal while using the application and come back to find out the site behaving in an unexpected manner because his session would have expired (default value for session timeout is 20 minutes). As a developer, it's a good practice to check a session variable for null value before using it, but you can create a much more user friendly environment by redirecting the user to a web page indicating that his session has timed out. The best way to do this is by creating a user control that you can just drop on your master or content page as desired.
I looked around for such solutions, and I have described below 2 such good implementations that should cover most scenarios.
Implementation 1
You can create a web control similar to what Peter Bromberg has outlined here.
This control checks for the HttpSessionState's IsNewSession property and the presence of the ASP.NET_SessionId cookie to determine if the user session has expired. It redirects the user to a timeout page if the session has expired. All you need to do is drop the control on your page and assign the RedirectURL property to your timeout page. The control works for both synchronous and aynchronous postbacks (for those of you using Asp.Net Ajax), and the only downfall for this method is that there's no way to warn the user that his page is about to timeout.
Implementation 2
If you would like to warn the user before his session actually times out, you can create an Asp.net AJAX friendly control similar to what Travis Collin's solution.
This control pops up a warning to the user some time before his session times out and gives him a chance to save his session. You can configure the UI of the warning and the time for warning and timeout while using the control. The only thing to watch out for here is that the developer has to make sure the session (and form) timeout value are in sync with the one configured on the control. I faced a small issue in this implementation because it was not recognizing asynchronous postbacks as user activity. To fix this, all i had to do was add a client side handler for page load and reset the timeout there as well.
    initialize : function() 
    {  
        ....
        Sys.Application.add_load(Function.createDelegate(this, this._handlePageLoaded));
        .....
    },
        _handlePageLoaded: function(sender, e)
    {
        this._resetTimeout();
    },

 Wednesday, August 20, 2008
Wednesday, August 20, 2008 4:59:17 PM (Mountain Standard Time, UTC-07:00) ( ajax | asp.net | extenders | Rounded Corners )

We noticed gaps in the borders for some of our controls while using the RoundedCorners Extender. This was a big headache since it seemed to work fine on some pages. I have included a sample image below.

We finally figured out that on the pages where it was not working, we were injecting some diagnostic information into our html as comments. Since this was being inserted before the doctype, it was sending IE into quirks mode and that was causing the trouble. Updating the code to insert comments after Doctype declaration fixed the issue.

Hope this helps somebody out there:).

-Latish Sehgal

 Tuesday, May 13, 2008
Tuesday, May 13, 2008 8:02:30 PM (Mountain Standard Time, UTC-07:00) ( )

You can follow me here.

 Friday, March 07, 2008
Friday, March 07, 2008 3:37:43 PM (Mountain Standard Time, UTC-07:00) ( Silverlight )

Check out the Silverlight implementation of John Conway's game of Life.

Keep an eye on your browser CPU Usage :).

 Wednesday, February 27, 2008
Wednesday, February 27, 2008 9:59:51 AM (Mountain Standard Time, UTC-07:00) ( .NET 3.5 | VS2008 )

Get it here.

This kit includes presentations, labs and demos.

Now only if I could find time to go through this :(.

 Monday, January 21, 2008
Monday, January 21, 2008 12:08:49 PM (Mountain Standard Time, UTC-07:00) ( MSEvent | VS2008 )
Registration for the "Heroes Happen Here" MSEvent has now begun.
You can find out more here.



Not only do you get to test drive the new products and meet the experts, but you also get free promotional versions of all 3 products. Its happening in Denver on March 20 at the Colorado Convention Center.

This is really cool, looking forward to this one!!! See you there.

-Latish Sehgal

 Wednesday, January 16, 2008
Wednesday, January 16, 2008 4:51:53 PM (Mountain Standard Time, UTC-07:00) ( )
Its here!! You can now debug the dot net source code in VS 2008. Read more about this in Shawn's post.
I am still not sure how beneficial this will be in day to day programming, but i guess it will be helpful in troubleshooting sometimes. Especially when it looks like we have found a bug in the framework :) (For the record, i never found a bug in the framework).
-Latish Sehgal

Wednesday, January 16, 2008 4:22:21 PM (Mountain Standard Time, UTC-07:00) ( oracle | sql )
Today i came across a new scenario in one of my applications (that talks to an oracle database) where we had to concatenate a field from multiple rows in a table into a single string. While some suggested that  string manipulation could be done inside the web application code after retrieving all the data, my alert (read over-caffeinated) brain was sure that there must be a way to tackle this at the database level by manipulating the sql query. 30 minutes with the Google gods proved me correct. I have created a brief test case with the solution below, if you run into a similar situation.
 To create the test table, run CreateTable.sql (.91 KB) after saving it to your system.
 Our table looks like this, and our goal is to create a concatenated string of all the names.


 
The sql uses SYS_CONNECT_BY_PATH() (used for hierarchial queries), and the final sql is

SELECT LTRIM(SYS_CONNECT_BY_PATH(Employee_Name, ','),',') Concatenated_Names
FROM (
      SELECT Employee_Name, ROW_NUMBER() OVER (order by Employee_Name) rownumber, COUNT(*) OVER () cnt
      FROM (SELECT Employee_Name FROM Employee)
) data
WHERE rownumber = cnt
START WITH rownumber = 1
CONNECT BY PRIOR rownumber = rownumber-1;

Below is the result of the query.


-Latish Sehgal
 Friday, January 11, 2008
Friday, January 11, 2008 12:25:03 PM (Mountain Standard Time, UTC-07:00) ( VS2008 | book review | linq )
MSPress has been offering free e-books for some time on VS2008 technologies. To get yours, go here and grab your copies. The LINQ book has all the chapters but the appendix on Ado.Net Entity framework, whereas the Ajax and Silverlight book have 2 sample chapters each.



I have been wanting to try out LINQ for some time. This is the perfect opportunity, i'll review the book as well as pick up something new. I'll post my review in a later post.
-Latish Sehgal