Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4550124
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:27:16+00:00 2026-05-21T16:27:16+00:00

I am seeing this error: Unable to cast object of type ‘System.Web.Profile.DefaultProfile’ to type

  • 0

I am seeing this error:

Unable to cast object of type ‘System.Web.Profile.DefaultProfile’ to type ‘ProfileCommon’.

on following code:

ProfileCommon p = (ProfileCommon)ProfileCommon.Create(TextUsername.Text, true);

I am not sure why…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:27:17+00:00Added an answer on May 21, 2026 at 4:27 pm

    Agree with theChrisKent.It’s look like problem in the web.config

    Check out the following example for,How to get ProfileCommon object in asp.net

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GetProfile" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            User Name:<asp:TextBox ID="txtUserName" runat="server"/>
            <asp:Button ID="cmdGet" runat="server" OnClick="cmdGet_Click" Text="Get Profile" /><br />
            <asp:Label ID="lbl" runat="server" Text=""/>
        </div>
        </form>
    </body>
    </html>
    

    File: Default.aspx.cs

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    public partial class GetProfile : System.Web.UI.Page
    {
      protected void cmdGet_Click(object sender, EventArgs e)
      {
        ProfileCommon profile = Profile.GetProfile(txtUserName.Text);
            if (profile.LastUpdatedDate == DateTime.MinValue)
            {
                lbl.Text = "No user match found.";
            }
            else
            {
                lbl.Text = "This user lives in " + profile.FirstName;
            }
      }
    }
    

    File: Web.config

    <?xml version="1.0"?>
    <configuration>
      <system.web>
        <profile>
          <properties>
            <add name="FirstName" type="String" serializeAs="Binary"/>
            <add name="LastName" type="String" serializeAs="Xml"/>
            <add name="DateOfBirth" type="DateTime" serializeAs="String"/>
          </properties>
        </profile>
      </system.web>
    </configuration>
    

    EDIT

    This example only work when the project type is website.If you want to use ProfileCommon object in Web Application then go through the following link

    Converting Profile Object Code

    EDIT -II

    As per your comment,Following link might help you

    ASP.NET Profiles in Web Application Projects

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lately, we've been seeing exceptions like this in our .NET (.asmx) webservices: System.Web.Services.Protocols.SoapException: Server
We've been seeing this error crop up in our system event logs an alarming
I'm seeing this error several times an hour on my production site and am
I am seeing this error intermittently. My app throws PageRequestManager is undefined and so
I deployed an update to my ASP.NET application and started seeing this error on
I'm seeing this in the Debugger Console: <Error>: CGImageSourceGetType image source parameter is nil\n
I'm seeing this error in my production server, sometimes (I mean, it seems random,
I'm currently seeing this error: MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Could not
I am seeing this error after I merged some changes from some one else's
I'm seeing this error on an iOS 4.3.5 handset where my app has been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.