ASP.NET 4 : Comparing the result set of an object and a string
<p>I am retrieving the contents of a database using a object (its returning only one field) and then comparing it with a string which has been hashed with SHA1 .The code is as follows :</p>

<pre><code>protected void Onbutton_click_login(object sender, System.EventArgs e)
    {
        var dbcontext = new PrepLicensingSolution2010.DAL.LicensingEntities1();
        var user = dbcontext.getloginname(loginName.Text);
        string HashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Text, "sha1");

        if (user.ToString() == HashedPassword)
        {
            Response.Redirect("faqs.aspx");

        }

        else
        {

            Response.Redirect("Default.aspx");
        }

    }
</code></pre>

<p>I put breakpoints and checked the data at each stage of the flow and the data in the object result set and in the string are the same but even then the conditional <strong>if</strong> fails
<img src="http://i.stack.imgur.com/CHkdU.png" alt="Breakpoint information"></p>

<p>whats interesting is both the types being compared are of the type string and of the same value,so why is that that the redirect goes to the default.aspx page.</p>

<p>The image contains the data from the breakpoints</p>

<p>Any inputs would be great.</p>

<p>Thanks</p>
