Wrox Programmer Forums
|
BOOK: Professional ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Professional ASP.NET 4 in C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470502204
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 1st, 2012, 08:11 AM
Authorized User
 
Join Date: Jul 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Post Anonymous Identification not working

Hi there, yesterday I tried the example in Listing 14-10 and it showed the GUID for .ASPXANONYMOUS cookie in fiddler. Yesterday it also showed the profile information that was stored in the database in the response webpage.

But today when I executed the same program, its showing message "You must be authenticated!" which must be because Page.User.Identity.IsAuthenticated returned true as can be seen from the code. Also the header now doesnt show the cookie.

When I remove anonymousIdentification property from the web.config and set authentication mode to Windows in web.config then it responds correctly.

I also tried it on my desktop, no difference.

Please help. Now I am unable proceed for remaining chapter.

Also tell me what sets property Page.User.Identity.IsAuthenticated.

One more question: Where these information is stored by default? Can we see it through SQL Server Management Studio?

I yesterday changed the default database to one empty database I created through aspnet_regsql.exe. I was able to see the stored information in Management Studio. But I was unable to see the same with default settings.


Personalization.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Personalization.aspx.cs"
    Inherits="Personalization" %>

<script runat="server">
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.User.Identity.IsAuthenticated)
        {
            string oldFirstName,oldLastName,oldAge,oldMember,oldLastVisited;
            oldFirstName = Profile.GetPropertyValue("FirstName").ToString();
            oldLastName = Profile.GetPropertyValue("LastName").ToString();
            oldAge = Profile.GetPropertyValue("Age").ToString();
            oldMember = Profile.GetPropertyValue("Member").ToString();
            oldLastVisited = Profile.GetPropertyValue("LastVisited").ToString();
            
            Profile.FirstName = TextBox1.Text;
            Profile.LastName = TextBox2.Text;
            Profile.Age = TextBox3.Text;
            Profile.Member = Radiobuttonlist1.SelectedItem.Text;
            Profile.LastVisited = DateTime.Now.ToString();         
            
            Label1.Text = "Stored information includes:<p>" +
            "First name: " + Profile.FirstName +
            "<br>Last name: " + Profile.LastName +
            "<br>Age: " + Profile.Age +
            "<br>Member: " + Profile.Member +
            "<br>Last visited: " + Profile.LastVisited+
            "<br/><br/> <b>     Latebound</b> Old Personalization Information"+
            "<br/>First name: "+oldFirstName+
            "<br/>Last Name: "+oldLastName+
            "<br/>Age: "+oldAge+
            "<br/>Member: "+oldMember+
            "<br/>Last visited: "+oldLastVisited;
            
        }
        else
        {
            Label1.Text = "You must be authenticated!";
        }
    }
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Storing Personalization</title>
</head>
<body>
    <form id="form1" runat="server">
    <p>
        First Name:
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></p>
    <p>
        Last Name:
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></p>
    <p>
        Age:
        <asp:TextBox ID="TextBox3" runat="server" Width="50px" MaxLength="3"></asp:TextBox></p>
    <p>
        Are you a member?
        <asp:RadioButtonList ID="Radiobuttonlist1" runat="server">
            <asp:ListItem Value="1">Yes</asp:ListItem>
            <asp:ListItem Value="0" Selected="True">No</asp:ListItem>
        </asp:RadioButtonList>
    </p>
    <p>
        <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
    </p>
    <hr />
    <p>
        <asp:Label ID="Label1" runat="server"></asp:Label></p>
    </form>
</body>
</html>
web.config
Code:
<?xml version="1.0"?>
<!--
				  For more information on how to configure your ASP.NET application, please visit
				  http://go.microsoft.com/fwlink/?LinkId=169433
				  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <profile>
      <properties>
        <add name="FirstName"/>
        <add name="LastName"/>
        <add name="LastVisited"/>
        <add name="Age"/>
        <add name="Member"/>
        <add name="Cart" type="ShoppingCart" serializeAs="Binary"/>
      </properties>
    </profile>
    <authentication mode="Windows" />    
    <anonymousIdentification enabled="true" />     
  </system.web>
  <!--
  <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=AspNetServicesDB;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings> -->
</configuration>

Last edited by Mahesha999; January 1st, 2012 at 08:14 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Working with Queries and Anonymous Types guynorton ASP.NET 3.5 Basics 1 October 10th, 2010 03:12 AM
About Anonymous Identification Lee Dumond BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 15 December 14th, 2008 05:12 PM
Regarding uniquely identification of every struts vishal_java2 Struts 0 April 11th, 2006 02:45 AM
Regarding uniquely identification of every struts vishal_java2 Struts 0 April 11th, 2006 02:42 AM
Session not working for Anonymous users songsan General .NET 0 January 4th, 2005 02:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.