1 Replies - 3279 Views - Last Post: 31 January 2013 - 10:26 PM Rate Topic: -----

#1 raniele3050  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-January 13

This property cannot be set for anonymous users.

Posted 31 January 2013 - 08:45 PM

I'm starting to learn c# and asp.net, because I want to start a career around it. I know it's ambitious, however I really want it. I've tried fixing it by myself, debugging (?) and googling for answers.

Here is the cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ProfileObject : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Profile.Preferences.Theme = "Retro";
        this.LiteralTheme.Text = Profile.Preferences.Theme;
    }
}



The aspx file:
<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="ProfileObject.aspx.cs" Inherits="ProfileObject" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <h1> Profile object </h1>
        Your selected theme:
        <asp:Literal ID="LiteralTheme" runat="server"></asp:Literal>

    </div>
    </form>
</body>
</html>




The error is:
Server Error in '/' Application.
This property cannot be set for anonymous users.
Exception Details: System.Configuration.Provider.ProviderException: This property cannot be set for anonymous users.


Hmm the problem is that I cannot make it work. Googling it tells me I need to set the database first. However I haven't set up any mysql or anything of the sort rather, I just want to learn about profile objects.

Is This A Good Question/Topic? 0
  • +

Replies To: This property cannot be set for anonymous users.

#2 raniele3050  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-January 13

Re: This property cannot be set for anonymous users.

Posted 31 January 2013 - 10:26 PM

Hey. Someone assisted me with this problem. Am just putting around his answer and my answer just in case if people get a similar problem.

You need to setup a place to store the profile objects. Without a database, it can't really be persistent as a profile. The error you are getting though, is to say that the property Theme cannot be set for anonymous users. An anonymous user is anyone who isn't logged in and authenticated. You can easily make the Theme property anonymous by tweaking the definition in the web.config file like so:
<add name="Theme" allowAnonymous="true" />
More infromation on the attributes you can use for the profile properties is at: http://msdn.microsof...(v=vs.100).aspx

And the code is:

<?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.5" />
      <httpRuntime targetFramework="4.5" />

      
      <anonymousIdentification  
   enabled="true"></anonymousIdentification>
        
      <profile>
        <properties>
          <group name="Preferences">
          <add name="Theme" allowAnonymous="true" />
          <add name="Currency"/>
          </group>
      </properties>
      </profile>

    </system.web>

</configuration>



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1