<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>hmloo's World of .NET</title>
        <link>http://geekswithblogs.net/hmloo/Default.aspx</link>
        <description />
        <language>en-US</language>
        <copyright>hmloo</copyright>
        <managingEditor>hmloo2012@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>hmloo's World of .NET</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/hmloo/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>(550) File unavailable (e.g., file not found, no access).</title>
            <category>C#</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/10/18/550-file-unavailable-e.g.-file-not-found-no-access.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/10/18/550-file-unavailable-e.g.-file-not-found-no-access.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/10/18/550-file-unavailable-e.g.-file-not-found-no-access.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;If you are getting above error while using &lt;strong&gt;&lt;em&gt;FtpWebRequest&lt;/em&gt;&lt;/strong&gt; method to upload file to a FTP sever, please check your URL, The URL must be case sensitive. Otherwise you will get this error.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/151011.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/10/18/550-file-unavailable-e.g.-file-not-found-no-access.aspx</guid>
            <pubDate>Thu, 18 Oct 2012 14:43:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/151011.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/10/18/550-file-unavailable-e.g.-file-not-found-no-access.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/151011.aspx</wfw:commentRss>
        </item>
        <item>
            <title>The remote server returned an error: 227 Entering Passive Mode</title>
            <category>C#</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/10/16/the-remote-server-returned-an-error-227-entering-passive-mode.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/10/16/the-remote-server-returned-an-error-227-entering-passive-mode.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/10/16/the-remote-server-returned-an-error-227-entering-passive-mode.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Today while uploading file to FTP sever, the codes throw an error - "The remote server returned an error: 227 Entering Passive Mode", after research, I got some knowledge in FTP working principle. &lt;/p&gt;  &lt;p&gt;FTP may run in active or passive mode, which determines how the data connection is established.&lt;/p&gt;  &lt;h6&gt;Active mode: &lt;/h6&gt;  &lt;p&gt;   &lt;br /&gt;command connection: client &amp;gt;1024  -&amp;gt; server 21     &lt;br /&gt;data connection:    client &amp;gt;1024  &amp;lt;-  server 20&lt;/p&gt;  &lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/hmloo/Windows-Live-Writer/d7486596d8dd_7CC5/active_2.gif" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="active" border="0" alt="active" src="http://gwb.blob.core.windows.net/hmloo/Windows-Live-Writer/d7486596d8dd_7CC5/active_thumb.gif" width="362" height="343" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h6&gt;passive mode: &lt;/h6&gt;  &lt;p&gt;   &lt;br /&gt;command connection: client &amp;gt; 1024 -&amp;gt; server 21     &lt;br /&gt;data connection:    client &amp;gt; 1024 &amp;lt;- server &amp;gt; 1024&lt;/p&gt;  &lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/hmloo/Windows-Live-Writer/d7486596d8dd_7CC5/passive_2.gif" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="passive" border="0" alt="passive" src="http://gwb.blob.core.windows.net/hmloo/Windows-Live-Writer/d7486596d8dd_7CC5/passive_thumb.gif" width="373" height="307" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In active mode, the client connects from a random unprivileged port (N &amp;gt; 1023) to the FTP server's command port(default port 21). If the client needs to transfer data, the client will use PORT command to tell the server:"hi, I opened port XXXX, please connect to me." and then server will use port 20 to initiate the data connection to that client port number. &lt;/p&gt;  &lt;p&gt;In passive mode, the client connects from a random unprivileged port (N &amp;gt; 1023) to the FTP server's command port(default port 21). If the client needs to transfer data, the sever will tell the client:"hi, I opened port XXXX , please connect to me." and then client will initiate the data connection to that sever port number. &lt;/p&gt;  &lt;p&gt;In a nutshell, active mode is used to have the server connect to the client, and passive mode is used to have the client connect to the server.&lt;/p&gt;  &lt;p&gt;So if your FTP server is configured to work in active mode only or the firewalls between your client and the server are blocking the data port range, then you will get error message, to fix this issue, just set &lt;strong&gt;&lt;em&gt;System.Net.FtpWebRequest&lt;/em&gt;&lt;/strong&gt; property &lt;strong&gt;&lt;em&gt;UsePassive = false&lt;/em&gt;&lt;/strong&gt;. &lt;/p&gt;  &lt;p&gt;Hope this helps! &lt;/p&gt;  &lt;p&gt;Thanks for reading! &lt;/p&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/151010.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/10/16/the-remote-server-returned-an-error-227-entering-passive-mode.aspx</guid>
            <pubDate>Wed, 17 Oct 2012 01:55:03 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/151010.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/10/16/the-remote-server-returned-an-error-227-entering-passive-mode.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/151010.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Web optimization</title>
            <category>CSS</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/09/13/web-optimization.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/09/13/web-optimization.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/09/13/web-optimization.aspx&lt;/a&gt;&lt;/p&gt;&lt;blockquote&gt; &lt;p&gt;1. CSS Optimization&lt;/p&gt;&lt;/blockquote&gt; &lt;h5&gt;Organize your CSS code&lt;/h5&gt; &lt;p&gt;Good CSS organization helps with future maintainability of the site, it helps you and your team member understand the CSS more quickly and jump to specific styles. &lt;/p&gt; &lt;h6&gt;Structure CSS code &lt;/h6&gt; &lt;p&gt;For small project, you can break your CSS code in separate blocks according to the structure of the page or page content. for example you can break your CSS document according the content of your web page(e.g. Header, Main Content, Footer) &lt;/p&gt; &lt;h6&gt;Structure CSS file &lt;/h6&gt; &lt;p&gt;For large project, you may feel having too much CSS code in one place, so it's the best to structure your CSS into more CSS files, and use a master style sheet to import these style sheets. this solution can not only organize style structure, but also reduce server request.&lt;/p&gt;&lt;pre class="brush: css;"&gt;/*--------------Master style sheet--------------*/
@import "Reset.css";
@import "Structure.css";
@import "Typography.css";
@import "Forms.css";&lt;/pre&gt;
&lt;h6&gt;Create index for your CSS&lt;/h6&gt;
&lt;p&gt;Another important thing is to create index at the beginning of your CSS file, index can help you quickly understand the whole CSS structure.&lt;/p&gt;&lt;pre class="brush: css;"&gt;/*----------------------------------------
1. Header
2. Navigation
3. Main Content
4. Sidebar
5. Footer
------------------------------------------*/&lt;/pre&gt;
&lt;h5&gt;Writing efficient CSS selectors&lt;/h5&gt;
&lt;p&gt;keep in mind that browsers match CSS selectors from &lt;strong&gt;right&lt;/strong&gt; to &lt;strong&gt;left&lt;/strong&gt; and the order of efficiency for selectors &lt;/p&gt;
&lt;p&gt;1. id (#myid) &lt;br /&gt;2. class (.myclass) &lt;br /&gt;3. tag (div, h1, p) &lt;br /&gt;4. adjacent sibling (h1 + p) &lt;br /&gt;5. child (ul &amp;gt; li) &lt;br /&gt;6. descendent (li a) &lt;br /&gt;7. universal (*) &lt;br /&gt;8. attribute (a[rel="external"]) &lt;br /&gt;9. pseudo-class and pseudo element (a:hover, li:first) &lt;/p&gt;
&lt;p&gt;the rightmost selector is called "key selector", so when you write your CSS code, you should choose more efficient key selector. Here are some best practice:&lt;/p&gt;
&lt;h6&gt;Don't tag-qualify&lt;/h6&gt;
&lt;p&gt;Never do this:&lt;/p&gt;&lt;p&gt;div#myid
&lt;br /&gt;div.myclass
&lt;br /&gt;.myclass#myid
&lt;/p&gt;
&lt;p&gt;IDs are unique, classes are more unique than a tag so they don't need a tag. Doing so makes the selector less efficient.&lt;/p&gt;
&lt;h6&gt;Avoid overqualifying selectors&lt;/h6&gt;
&lt;p&gt;for example&lt;/p&gt;&lt;p&gt;#nav a
&lt;/p&gt;
&lt;p&gt;is more efficient than&lt;/p&gt;&lt;p&gt;ul#nav li a&lt;/p&gt;
&lt;br /&gt;
&lt;h6&gt;Don't repeat declaration&lt;/h6&gt;&lt;strong&gt;Example:&lt;/strong&gt; 
&lt;p&gt;body {&lt;font color="#ff0000"&gt;font-size:12px;}&lt;br /&gt;&lt;/font&gt;h1 {&lt;font color="#ff0000"&gt;font-size:12px;&lt;/font&gt;font-weight:bold;}&lt;/p&gt;
&lt;p&gt;since h1 is already inherited from body, so you don't need to repeate atrribute.&lt;/p&gt;
&lt;h6&gt;Using 0 instead of 0px&lt;/h6&gt;
&lt;p&gt;Always using #selector { margin: 0; } There’s no need to include the &lt;strong&gt;px&lt;/strong&gt; after 0, removing all those superfluous px can reduce the size of your CSS file. 
&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;h6&gt;Group declaration &lt;/h6&gt;&lt;strong&gt;Example:&lt;/strong&gt; &lt;pre class="brush: css;"&gt;h1
{
    font-size: 16pt;
}

h1
{
    color: #fff;
}

h1
{
    font-family: Arial, sans-serif;
}&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;it’s much better to combine them:&lt;/p&gt;&lt;pre class="brush: css;"&gt;h1
{
    font-size: 16pt;
    color: #fff;
    font-family: Arial, sans-serif;
}&lt;/pre&gt;
&lt;h6&gt;Group selectors&lt;/h6&gt;&lt;strong&gt;Example:&lt;/strong&gt; &lt;pre class="brush: css;"&gt;h1
{
    color: #fff;
    font-family: Arial, sans-serif;
}

h2
{
    color: #fff;
    font-family: Arial, sans-serif;
}&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;it would be much better if setup as:&lt;/p&gt;&lt;pre class="brush: css;"&gt;h1, h2
{
    color: #fff;
    font-family: Arial, sans-serif;
}&lt;/pre&gt;&lt;br /&gt;
&lt;h6&gt;Group attribute&lt;/h6&gt;&lt;strong&gt;Example:&lt;/strong&gt; &lt;pre class="brush: css;"&gt;h1
{
    color: #fff;
    font-family: Arial, sans-serif;
}

h2
{
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 16pt;
}&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;you can set different rules for specific elements after setting a rule for a group&lt;/p&gt;&lt;pre class="brush: css;"&gt;h1, h2
{
    color: #fff;
    font-family: Arial, sans-serif;
}

h2
{
    font-size: 16pt;
}&lt;/pre&gt;&lt;br /&gt;
&lt;h6&gt;Using Shorthand Properties&lt;/h6&gt;&lt;strong&gt;Example:&lt;/strong&gt; &lt;pre class="brush: css;"&gt;#selector
{   
 margin-top: 8px;  
 margin-right: 4px;  
 margin-bottom: 8px;  
 margin-left: 4px;
}&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Better:&lt;/strong&gt; &lt;pre class="brush: css;"&gt;#selector
{  
 margin: 8px 4px 8px 4px;
}&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Best:&lt;/strong&gt; &lt;pre class="brush: css;"&gt;#selector
{   
 margin: 8px 4px;
}&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;a good diagram illustrated how shorthand declarations are interpreted depending on how many values are specified for margin and padding property.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/hmloo/Windows-Live-Writer/4689dce43c51_74E7/Untitled_2.jpg" rel="lightbox"&gt;&lt;img style="display: inline" title="Untitled" alt="Untitled" src="http://gwb.blob.core.windows.net/hmloo/Windows-Live-Writer/4689dce43c51_74E7/Untitled_thumb.jpg" width="539" height="229" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;instead of using:&lt;/p&gt;&lt;pre class="brush: css;"&gt;#selector
{   
  background-image: url(”logo.png”);
  background-position: top left;
  background-repeat: no-repeat;
}&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;is used:&lt;/p&gt;&lt;pre class="brush: css;"&gt;#selector
{   
  background: url(logo.png) no-repeat top left;
}&lt;/pre&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;p&gt;2. Image Optimization&lt;/p&gt;&lt;/blockquote&gt;
&lt;h6&gt;Image Optimizer&lt;/h6&gt;
&lt;p&gt;Image Optimizer is a free Visual Studio2010 extension that optimizes PNG, GIF and JPG file sizes without quality loss. It uses &lt;a href="http://www.smushit.com/ysmush.it/"&gt;SmushIt&lt;/a&gt; and &lt;a href="http://punypng.com/"&gt;PunyPNG&lt;/a&gt; for the optimization. Just right click on any folder or images in Solution Explorer and choose optimize images, then it will automatically optimize all PNG, GIF and JPEG files in that folder. &lt;/p&gt;
&lt;h6&gt;CSS Image Sprites&lt;/h6&gt;
&lt;p&gt;CSS Image Sprites are a way to combine a collection of images to a single image, then use CSS &lt;em&gt;background-position&lt;/em&gt; property to shift the visible area to show the required image, many images can take a long time to load and generates multiple server requests, so Image Sprite can reduce the number of server requests and improve site performance. &lt;br /&gt;You can use many online tools to generate your image sprite and CSS, and you can also try the &lt;a href="http://aspnet.codeplex.com/releases/view/65787"&gt;Sprite and Image Optimization&lt;/a&gt; framework released by The ASP.NET team.&lt;/p&gt;&lt;pre&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/150704.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/09/13/web-optimization.aspx</guid>
            <pubDate>Fri, 14 Sep 2012 02:18:19 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/150704.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/09/13/web-optimization.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/150704.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to Implement Single Sign-On between Websites</title>
            <category>C#</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/07/09/how-to-implement-single-sign-on-between-websites.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/07/09/how-to-implement-single-sign-on-between-websites.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/07/09/how-to-implement-single-sign-on-between-websites.aspx&lt;/a&gt;&lt;/p&gt;&lt;blockquote&gt;   &lt;p&gt;Introduction&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Single sign-on (SSO) is a way to control access to multiple related but independent systems, a user only needs to log in once and gains access to all other systems. a lot of commercial systems that provide Single sign-on solution and you can also choose some open source solutions like &lt;a href="https://opensso.dev.java.net/"&gt;Opensso&lt;/a&gt;, &lt;a href="http://www.jasig.org/cas"&gt;CAS&lt;/a&gt; etc. both of them use centralized authentication and provide more robust authentication mechanism, but if each system has its own authentication mechanism, how do we provide a seamless transition between them. Here I will show you the case.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;How it Works&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The method we’ll use is based on a secret key shared between the sites. Origin site has a method to build up a hashed authentication token with some other parameters and redirect the user to the target site.&lt;/p&gt;  &lt;table class="wiki_table"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;th&gt;variables &lt;/th&gt;        &lt;th&gt;Status &lt;/th&gt;        &lt;th&gt;Description &lt;/th&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;ssoEncode&lt;/td&gt;        &lt;td&gt;required&lt;/td&gt;        &lt;td&gt;hash(ssoSharedSecret + , + ssoTime + , + ssoUserName)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;ssoTime&lt;/td&gt;        &lt;td&gt;required&lt;/td&gt;        &lt;td&gt;timestamp with format YYYYMMDDHHMMSS used to prevent playback attacks &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;ssoUserName &lt;/td&gt;        &lt;td&gt;required &lt;/td&gt;        &lt;td&gt;unique username; required when a user is logged in &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Note : The variables will be sent via POST for security reasons&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Building a Single Sign-On Solution&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Origin Site has function to    &lt;br /&gt;1. Create the URL for your Request.     &lt;br /&gt;2. Generate required authentication parameters     &lt;br /&gt;3. Redirect to target site.&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;using System;
using System.Web.Security;
using System.Text;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string postbackUrl = "http://www.targetsite.com/sso.aspx";
        string ssoTime = DateTime.Now.ToString("yyyyMMddHHmmss");
        string ssoUserName = User.Identity.Name;
        string ssoSharedSecret = "58ag;ai76"; // get this from config or similar
        string ssoHash = FormsAuthentication.HashPasswordForStoringInConfigFile(string.Format("{0},{1},{2}", ssoSharedSecret, ssoTime, ssoUserName), "md5");
        string value = string.Format("{0}:{1},{2}", ssoHash,ssoTime, ssoUserName);
        Response.Clear();
        StringBuilder sb = new StringBuilder();
        sb.Append("&amp;lt;html&amp;gt;");
        sb.AppendFormat(@"&amp;lt;body onload='document.forms[""form""].submit()'&amp;gt;");
        sb.AppendFormat("&amp;lt;form name='form' action='{0}' method='post'&amp;gt;", postbackUrl);
        sb.AppendFormat("&amp;lt;input type='hidden' name='t' value='{0}'&amp;gt;", value);
        sb.Append("&amp;lt;/form&amp;gt;");
        sb.Append("&amp;lt;/body&amp;gt;");
        sb.Append("&amp;lt;/html&amp;gt;");
        Response.Write(sb.ToString());
        Response.End();

    }
}&lt;/pre&gt;

&lt;br /&gt;

&lt;p&gt;Target Site has function to 
  &lt;br /&gt;1. Get authentication parameters. 

  &lt;br /&gt;2. Validate the parameters with shared secret. 

  &lt;br /&gt;3. If the user is valid, then do authenticate and redirect to target page. 

  &lt;br /&gt;4. If the user is invalid, then show errors and return.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;using System;
using System.Web.Security;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (User.Identity.IsAuthenticated)
            {
                Response.Redirect("~/Default.aspx");
            }
        }
        if (Request.Params.Get("t") != null)
        {
            string ticket = Request.Params.Get("t");
            char[] delimiters = new char[] { ':', ',' };
            string[] ssoVariable = ticket.Split(delimiters, StringSplitOptions.None);
            string ssoHash = ssoVariable[0];
            string ssoTime = ssoVariable[1];
            string ssoUserName = ssoVariable[2];
            DateTime appTime = DateTime.MinValue;
            int offsetTime = 60; // get this from config or similar
            try
            {
                appTime = DateTime.ParseExact(ssoTime, "yyyyMMddHHmmss", null);
            }
            catch
            {
                //show error
                return;
            }
            if (Math.Abs(appTime.Subtract(DateTime.Now).TotalSeconds) &amp;gt; offsetTime)
            {
                //show error
                return;
            }
            bool isValid = false;
            string ssoSharedSecret = "58ag;ai76"; // get this from config or similar
            string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(string.Format("{0},{1},{2}", ssoSharedSecret, ssoTime, ssoUserName), "md5");
            if (string.Compare(ssoHash, hash, true) == 0)
            {
                if (Math.Abs(appTime.Subtract(DateTime.Now).TotalSeconds) &amp;gt; offsetTime)
                {
                    //show error
                    return;
                }
                else
                {
                    isValid = true;
                }
            }
            if (isValid)
            {
                //Do authenticate;
            }
            else
            {
                //show error
                return;
            }
        }
        else
        {
            //show error
        }
    }
}&lt;/pre&gt;

&lt;blockquote&gt;
  &lt;p&gt;Summary&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a very simple and basic SSO solution, and its main advantage is its simplicity, only needs to add a single page to do SSO authentication, do not need to modify the existing system infrastructure.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/150190.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/07/09/how-to-implement-single-sign-on-between-websites.aspx</guid>
            <pubDate>Tue, 10 Jul 2012 07:42:32 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/150190.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/07/09/how-to-implement-single-sign-on-between-websites.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/150190.aspx</wfw:commentRss>
        </item>
        <item>
            <title>My Generation Drivers DropdownList Empty</title>
            <category>Developer Tools</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/07/01/my-generation-drivers-dropdownlist-empty.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/07/01/my-generation-drivers-dropdownlist-empty.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/07/01/my-generation-drivers-dropdownlist-empty.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I just installed MyGeneration 1.3.1 on my Windows Vista, and when I try to setup the default settings there are no drivers to select from. but it's OK in my Windows XP machine. At last I got the answers from search engine, it is caused by multi .Net Frameworks coexist and MyMeta.dll is registered by the .Net v2.0 while it should be registered with the .Net v4.0. So we have to manually register the dll. Please follow these steps:    &lt;br /&gt;1. Run Visual Studio Command Prompt (2010) with "Run as Administrator".     &lt;br /&gt;2. Enter the command "regasm.exe "C:\Program Files\MyGeneration13\MyMeta.dll" /tlb: MyMeta.tlb"     &lt;br /&gt;3. Exit Command Prompt when successfully registered.     &lt;br /&gt;4. Run MyGeneration and the proplem should be disapear.     &lt;br /&gt;Hope this helps.     &lt;br /&gt;Thanks for reading.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/150096.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/07/01/my-generation-drivers-dropdownlist-empty.aspx</guid>
            <pubDate>Mon, 02 Jul 2012 04:57:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/150096.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/07/01/my-generation-drivers-dropdownlist-empty.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/150096.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Encryption and Decryption in the .NET Framework</title>
            <category>C#</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/05/23/encryption-and-decryption-in-the-.net-framework.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/05/23/encryption-and-decryption-in-the-.net-framework.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/05/23/encryption-and-decryption-in-the-.net-framework.aspx&lt;/a&gt;&lt;/p&gt;&lt;blockquote&gt;   &lt;p&gt;What Is Symmetric Encryption?&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="125" alt="image" src="http://gwb.blob.core.windows.net/hmloo/WindowsLiveWriter/EncryptionandDecryptioninth.NETFramework_96CD/image_14.png" width="544" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;Symmetric encryption uses the same key for both encryption and decryption.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Symmetric Algorithm in the .NET Framework&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;img title="SymmetricAlgorithm" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="266" alt="SymmetricAlgorithm" src="http://gwb.blob.core.windows.net/hmloo/WindowsLiveWriter/EncryptionandDecryptioninth.NETFramework_96CD/SymmetricAlgorithm_3.png" width="543" border="0" /&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;What Is Asymmetric Encryption?&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="118" alt="image" src="http://gwb.blob.core.windows.net/hmloo/WindowsLiveWriter/EncryptionandDecryptioninth.NETFramework_96CD/image_13.png" width="528" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;Asymmetric cryptography uses separate keys for encryption and decryption&lt;/p&gt;  &lt;p&gt;Encrypted Text with public key can be decrypted only with the private key&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Asymmetric Algorithm in the .NET Framework&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;img title="AsymmetricAlgorithm," style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="206" alt="AsymmetricAlgorithm," src="http://gwb.blob.core.windows.net/hmloo/WindowsLiveWriter/EncryptionandDecryptioninth.NETFramework_96CD/AsymmetricAlgorithm,_3.png" width="523" border="0" /&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Hash Algorithm &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt; &lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="131" alt="image" src="http://gwb.blob.core.windows.net/hmloo/WindowsLiveWriter/EncryptionandDecryptioninth.NETFramework_96CD/image_20.png" width="370" border="0" /&gt; &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Has Algorithm in the .NET Framework&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;img title="HashAlgorithm" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="253" alt="HashAlgorithm" src="http://gwb.blob.core.windows.net/hmloo/WindowsLiveWriter/EncryptionandDecryptioninth.NETFramework_96CD/HashAlgorithm_3.png" width="488" border="0" /&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;What is Digital Signature?&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="217" alt="image" src="http://gwb.blob.core.windows.net/hmloo/WindowsLiveWriter/EncryptionandDecryptioninth.NETFramework_96CD/image_23.png" width="469" border="0" /&gt; &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Hash + Asymmetric Encryption = Digital Signature&lt;/strong&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/149719.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/05/23/encryption-and-decryption-in-the-.net-framework.aspx</guid>
            <pubDate>Thu, 24 May 2012 02:37:22 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/149719.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/05/23/encryption-and-decryption-in-the-.net-framework.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/149719.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to remove the last character from Stringbuilder</title>
            <category>C#</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/04/08/how-to-remove-the-last-character-from-stringbuilder.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/04/08/how-to-remove-the-last-character-from-stringbuilder.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/04/08/how-to-remove-the-last-character-from-stringbuilder.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;We usually use StringBuilder to append string in loops and make a string of each data separated by a delimiter. but you always end up with an extra delimiter at the end. This code sample shows how to remove the last delimiter from a StringBuilder. &lt;/p&gt;  &lt;pre class="brush: csharp; toolbar: false; auto-links: false;"&gt;using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    static void Main()
    {
        var list =Enumerable.Range(0, 10).ToArray();
        StringBuilder sb = new StringBuilder();
        foreach(var item in list)
        {
            sb.Append(item).Append(",");
        }
        sb.Length--;//Just reduce the length of StringBuilder, it's so easy
        Console.WriteLine(sb);
    }
}

//Output : 0,1,2,3,4,5,6,7,8,9&lt;/pre&gt;

&lt;p&gt;Alternatively,  we can use &lt;a href="http://msdn.microsoft.com/en-us/library/system.string.join.aspx"&gt;string.Join&lt;/a&gt; for the same results, please refer to blow code sample.&lt;/p&gt;

&lt;pre class="brush: csharp; toolbar: false; auto-links: false;"&gt;using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    static void Main()
    {
        var list = Enumerable.Range(0, 10).Select(n =&amp;gt; n.ToString()).ToArray();
        string str = string.Join(",", list);
        Console.WriteLine(str);
    }
}&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/149257.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/04/08/how-to-remove-the-last-character-from-stringbuilder.aspx</guid>
            <pubDate>Mon, 09 Apr 2012 00:12:27 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/149257.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/04/08/how-to-remove-the-last-character-from-stringbuilder.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/149257.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to create Checkboxes that act like Radio buttons with Jquery</title>
            <category>Jquery</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/03/22/how-to-create-checkboxes-that-act-like-radio-buttons-with.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/03/22/how-to-create-checkboxes-that-act-like-radio-buttons-with.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/03/22/how-to-create-checkboxes-that-act-like-radio-buttons-with.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I have a post &lt;a href="http://geekswithblogs.net/hmloo/archive/2012/02/15/how-to-checkuncheck-all-checkbox-with-jquery.aspx"&gt;here&lt;/a&gt; to show code examples for check/uncheck all checkbox with Jquery. This time I will implement another request that the user should only be able to check at most one of the checkboxes, it's behave like radio buttons.&lt;/p&gt;  &lt;p&gt;There are 2 cases. Case 1 shows function that has little difference with radio button. It allows the user to deselect checkbox. Case 2 is same as radio button. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Case 1 &lt;/strong&gt;&lt;/p&gt;  &lt;pre class="brush: js; toolbar: false; auto-links: false;"&gt;&amp;lt;head id="Head1" runat="server"&amp;gt; 
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt; 
    &amp;lt;script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt; 
    &amp;lt;style type="text/css"&amp;gt; 
           .cbRowItem {display:block;} 
     &amp;lt;/style&amp;gt; 
    &amp;lt;script type="text/javascript"&amp;gt; 
    $(document).ready(function() 
    { 
        var $chk = $('input:checkbox .cbRowItem'); 
        $chk.click(function() 
        { 
            $chk.not(this).removeAttr('checked'); 
        }); 
    }); 
  &amp;lt;/script&amp;gt; 
&amp;lt;/head&amp;gt; 
&amp;lt;body&amp;gt; 
    &amp;lt;form id="form1" runat="server"&amp;gt; 
    &amp;lt;div style="display:block;"&amp;gt; 
    &amp;lt;asp:CheckBox id="CheckBox1" runat="server" class="cbRowItem" Text = "CheckBox 1"/&amp;gt; 
    &amp;lt;asp:CheckBox id="CheckBox2" runat="server" class="cbRowItem" Text = "CheckBox 2"/&amp;gt; 
    &amp;lt;asp:CheckBox id="CheckBox3" runat="server" class="cbRowItem" Text = "CheckBox 3"/&amp;gt; 
    &amp;lt;asp:CheckBox id="CheckBox4" runat="server" class="cbRowItem" Text = "CheckBox 4"/&amp;gt; 
    &amp;lt;/div&amp;gt; 
    &amp;lt;/form&amp;gt; 
&amp;lt;/body&amp;gt; 
&amp;lt;/html&amp;gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Case 2&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="brush: js; toolbar: false; auto-links: false;"&gt;&amp;lt;head id="Head1" runat="server"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
    &amp;lt;script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;style type="text/css"&amp;gt;
           .cbRowItem {display:block;}
     &amp;lt;/style&amp;gt;
    &amp;lt;script type="text/javascript"&amp;gt;
    $(document).ready(function()
    {
        var $chk = $('input:checkbox .cbRowItem'); 
        $chk.click(function()
        {
            $chk.removeAttr('checked');
            $(this).attr('checked', 'checked');
        });
    });
  &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form id="form1" runat="server"&amp;gt;
    &amp;lt;div style="display:block;"&amp;gt;
    &amp;lt;asp:CheckBox id="CheckBox1" runat="server" class="cbRowItem" Text = "CheckBox 1"/&amp;gt;
    &amp;lt;asp:CheckBox id="CheckBox2" runat="server" class="cbRowItem" Text = "CheckBox 2"/&amp;gt;
    &amp;lt;asp:CheckBox id="CheckBox3" runat="server" class="cbRowItem" Text = "CheckBox 3"/&amp;gt;
    &amp;lt;asp:CheckBox id="CheckBox4" runat="server" class="cbRowItem" Text = "CheckBox 4"/&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/149085.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/03/22/how-to-create-checkboxes-that-act-like-radio-buttons-with.aspx</guid>
            <pubDate>Fri, 23 Mar 2012 01:22:47 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/149085.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/03/22/how-to-create-checkboxes-that-act-like-radio-buttons-with.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/149085.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Replace broken image with noimage icon using Jquery</title>
            <category>Jquery</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/03/20/replace-broken-image-with-noimage-icon-using-jquery.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/03/20/replace-broken-image-with-noimage-icon-using-jquery.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/03/20/replace-broken-image-with-noimage-icon-using-jquery.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Sometimes when the image isn't available on server, the web page will show a broken image. so we can display a "no image available" image for good user experience. I will implement it using Jquery.&lt;/p&gt;  &lt;pre class="brush: js; toolbar: false; auto-links: false;"&gt;$(document).ready(function()
{
    $("img").error(function()
    {
        $(this).hide();
    })
    .attr("src", "noimage.jpg");
});&lt;/pre&gt;

&lt;p&gt;Please note that we must first hide the broken image, or else even if we set the src to noimage, it still can not show  noimage icon.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/149062.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/03/20/replace-broken-image-with-noimage-icon-using-jquery.aspx</guid>
            <pubDate>Wed, 21 Mar 2012 07:23:55 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/149062.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/03/20/replace-broken-image-with-noimage-icon-using-jquery.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/149062.aspx</wfw:commentRss>
        </item>
        <item>
            <title>The device is not ready</title>
            <category>C#</category>
            <link>http://geekswithblogs.net/hmloo/archive/2012/03/18/device-is-not-ready-error.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/hmloo/archive/2012/03/18/device-is-not-ready-error.aspx'&gt;http://geekswithblogs.net/hmloo/archive/2012/03/18/device-is-not-ready-error.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;When you retrieve the drive info using the &lt;strong&gt;DriveInfo&lt;/strong&gt; class, if you don't use the &lt;strong&gt;IsReady&lt;/strong&gt; property to test whether a drive is ready, it will throw error as "&lt;strong&gt;The device is not ready&lt;/strong&gt;". so you must use &lt;strong&gt;IsReady&lt;/strong&gt; property to determines if the drive is ready to be queried, written to, or read from. The following code example demonstrates querying information for all drives on current system.&lt;/p&gt;  &lt;pre class="brush: csharp; toolbar: false; auto-links: false;"&gt;using System;
using System.IO;

class Test
{
    public static void Main()
    {
        DriveInfo[] allDrives = DriveInfo.GetDrives();

        foreach (DriveInfo d in allDrives)
        {
            Console.WriteLine("Drive {0}", d.Name);
            Console.WriteLine("  File type: {0}", d.DriveType);
            if (d.IsReady == true)
            {
                Console.WriteLine("  Volume label: {0}", d.VolumeLabel);
                Console.WriteLine("  File system: {0}", d.DriveFormat);
                Console.WriteLine(
                    "  Available space to current user:{0, 15} bytes", 
                    d.AvailableFreeSpace);

                Console.WriteLine(
                    "  Total available space:          {0, 15} bytes",
                    d.TotalFreeSpace);

                Console.WriteLine(
                    "  Total size of drive:            {0, 15} bytes ",
                    d.TotalSize);
            }
        }
    }
}&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/hmloo/aggbug/149045.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>hmloo</dc:creator>
            <guid>http://geekswithblogs.net/hmloo/archive/2012/03/18/device-is-not-ready-error.aspx</guid>
            <pubDate>Mon, 19 Mar 2012 06:16:44 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/hmloo/comments/149045.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/hmloo/archive/2012/03/18/device-is-not-ready-error.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/hmloo/comments/commentRss/149045.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>