Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 February 18th, 2011, 03:16 PM
Registered User
 
Join Date: Sep 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Created a profile but error elements are not accessible

Around page 562, I'm following the instructions to create a profile. But after creating the profile elements and compiling the app I can't reference those elements.

In the project's (not web site) root is web.config and I've modified the profile <system.web> section like so:

Code:
    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
      </providers>
      <properties>
        <add name ="favoritetea" allowAnonymous="true"/>
      </properties>
    </profile>
In the website's defualt.aspx (which is the page first loaded with the master page) I try to set a value for "favoritetea" and it's not happy. No intellisense and on compile an error appears

'favoritetea' is not a member of 'Profile'

Here is that page's onload code:

Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Profile.favoritetea = "earl grey"

    End Sub
I may be wrong but I discount the fact that I'm using a asp.net project instead of a web site, and that I'm using a masterpage as issues, because it's not a runtime issue, it won't even compile.
 
Old February 18th, 2011, 03:54 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I may be wrong but I discount the fact that I'm using a asp.net project instead of a web site, and that I'm using a masterpage as issues, because it's not a runtime issue, it won't even compile.

It *is* caused by the fact you're using a Web Application Project and not a Web Site Project.

Web Site Projects support dynamic compilation and can create, and attach the Profile property to the Page class on the fly. With a Web Application Project, this doesn't happen, and thus the Profile properties won't exist and thus your code doesn't compile.

If you want to follow along with the book, you need a Web Site Project as explained in the early chapters. Alternatively, you can look into other solutions:

http://webcache.googleusercontent.co...www.google.com

http://archive.msdn.microsoft.com/WebProfileBuilder

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old February 18th, 2011, 04:12 PM
Registered User
 
Join Date: Sep 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, thanks Imar!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Appendix B error Unrecognized configuration section profile davidh08 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 August 20th, 2009 07:28 AM
Subs in module not accessible!? LenexaKS ASP.NET 2.0 Basics 4 May 31st, 2007 08:06 AM
Error : Mutex could not be created Rohit Ranjan .NET Web Services 1 November 14th, 2005 10:58 AM
accessible forms nclisgo BOOK: Accessible XHTML and CSS Web Sites: Problem Design Solution 0 June 9th, 2005 05:57 AM
"An error log is being created"... where? MelissaEvans Beginning VB 6 5 January 14th, 2005 06:39 AM





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