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 July 5th, 2010, 11:58 PM
Authorized User
 
Join Date: Dec 2009
Posts: 63
Thanks: 18
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Wilfredo Rosado
Default My Profile

I'm having problems with setting up the profile on pages 562 & 563. After typing everything in I am getting an error message when I try to preview it in the browser. The error message is:

Code:
System.Configuration.Provider.ProviderException: This property cannot be set for anonymous users.

Source Error: 

Line 97:        End Get
Line 98:        Set
Line 99:            Me.SetPropertyValue("FirstName", value)
Line 100:       End Set
Line 101:   End Property
 
Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\b5814cd2\c8a96329\App_Code.6s5bqrmx.2.vb    Line: 99
Web.config:
Code:
    <profile>
      <properties>
        <add name="FirstName" />
        <add name="LastName" />
        <add name="Address1" />
        <add name="Address2" />
        <add name="City" />
        <add name="State" />
        <add name="Zipcode" />
        <add name="ZipExt" />
        <add name="County" />
        <add name="Country" />
        <add name="PhoneAreaCode" />
        <add name="PhoneNumber" />
        <add name="Email" />
        <add name="EmailType" />
      </properties>
    </profile>
    <roleManager enabled="true"/>

  <location path="MyProfile.aspx">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>
</configuration>
MyProfile.aspx.vb codebehind:
Code:
Partial Class MyProfile
  Inherits BasePage

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Profile.FirstName = "Your First Name"
    Profile.LastName = "Your Last Name"
    Profile.Address1 = "Your address first line"
    Profile.Address2 = "Your address second line"
    Profile.City = "Tour City name"
  End Sub
End Class
Does anybody have an idea?

Fred Rosado
 
Old July 6th, 2010, 02:02 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Fred,

A few things to check:

1. Did you enable forms authentication in the web.config file?

2. Is MyProfile.aspx located in the root of the site and not in a subfolder?

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 July 6th, 2010, 02:06 AM
Authorized User
 
Join Date: Dec 2009
Posts: 63
Thanks: 18
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Wilfredo Rosado
Default

Hi Imar,

Quote:
Originally Posted by Imar View Post
Hi Fred,
2. Is MyProfile.aspx located in the root of the site and not in a subfolder?
Imar
I have number 1 done correctly, but No2 in quote above was moved under a folder called about.

Fred
 
Old July 6th, 2010, 02:17 AM
Authorized User
 
Join Date: Dec 2009
Posts: 63
Thanks: 18
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Wilfredo Rosado
Thumbs down Confused

Imar,

I moved it back to the root and then modified web.sitemap accordingly and now it works.

I'm a little confused as to why some things have to be at the root and also as to why ~/ doesn't always work, especially for pictures and I have to use ../ instead. I thought using the tilde was supposed to be the best thing to use especially when publishing to a different server?

Fred
 
Old July 6th, 2010, 02:40 AM
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 moved it back to the root and then modified web.sitemap accordingly and now it works.
Instead of moving it back and updating web.sitemap, you can also update web.config:

Code:
 <location path="About/MyProfile.aspx">
  <system.web>
    <authorization>
      <deny users="?"/>
    </authorization>
  </system.web>
</location>
Your initial code wasn't protecting /About/Myprofile.aspx, but /Myprofile.aspx. It thus didn't force you to log in and thus you can't set properties that are not enabled for anonymous users.

Quote:
I thought using the tilde was supposed to be the best thing to use especially when publishing to a different server?
Yes, as long as you're dealing with server side controls.

This doesn't work:

<img src="~/Images/SomeImage.png" .... />

but this does:

<img src="~/Images/SomeImage.png" runat="server" .... />

Hope this helps,

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!
The Following User Says Thank You to Imar For This Useful Post:
Wilfredo Rosado (July 6th, 2010)
 
Old July 6th, 2010, 03:39 AM
Authorized User
 
Join Date: Dec 2009
Posts: 63
Thanks: 18
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Wilfredo Rosado
Default

Imar,

I moved MyProfile.aspx back under the about folder and modified my location, as you specified, in web.config and it is still working - - Thanks so much!

If I understand you correctly then; any file that I do not want at the root all I have to do is move the file where I want it and specify its location in the web.config? Yes/No?

As for the picture problem I was having understanding the tilde, I think I have it straight for the <img> tag. What about the <asp:Image> tag? I have the following:
Code:
<a href='<%# Eval("Path") + "Photos/" + Eval("PicName") + "_En.JPG" %>' >
   <asp:Image ID="Image1" runat="server" ToolTip="Click the image to enlarge it." 
       ImageUrl='<%# Eval("Path") + "Thumbnail/" + Eval("PicName") + "_Th.JPG" %>' />
When the Path is set to "../images/Home3/Bath2ndFlr/" it works, but not when its "~/images". It creates a string like so: "/PhotoAlbum/~/Images/Home3/Bath2ndFlr/Photos/6110001_En.JPG". The file that was currently running trying to display the image was under the PhotoAlbum folder.

I have a thought! Can I use the eval() in an <img> tag?Then I can use it as you specified.

Like always Imar thanks so much.

Fred
 
Old July 6th, 2010, 03:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
If I understand you correctly then; any file that I do not want at the root all I have to do is move the file where I want it and specify its location in the web.config? Yes/No?
Normally, no, you don't have to list the file anywhere in web.config. However, if you want to enforce authentication for that file, then yes.

The image and the ~ shouldn't behave as you're describing. Take a look at Default.aspx in the PhotoAlbums folder. I am doing the exact same thing, and bind to a URL starting with a ~ from the database. That works fine. Where / how exactly are you using that code?

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!
The Following User Says Thank You to Imar For This Useful Post:
Wilfredo Rosado (July 6th, 2010)
 
Old July 6th, 2010, 04:13 AM
Authorized User
 
Join Date: Dec 2009
Posts: 63
Thanks: 18
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Wilfredo Rosado
Default

Alright Imar,

You are like always 100% correct! I found where I was going wrong. Unlike your default.aspx <asp:Image> tag, I used an anchor <a> tag to display a larger image of the thumbnail image when clicked on. My anchor tag didn't have the runat="server". Now it does and everything is fine! I'm so happy I'm going to sleep as I am again tired at 4:10AM. Nice talking with you.

Good-nite and thanks,
Fred





Similar Threads
Thread Thread Starter Forum Replies Last Post
Profile danievermaak BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 3 July 5th, 2010 09:26 PM
profile sophia BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 9 November 30th, 2009 10:51 AM
how to use shoppingcart without profile? hertendreef ASP.NET 2.0 Basics 6 January 11th, 2007 05:16 AM
profile object davyquyo ASP.NET 2.0 Basics 6 December 28th, 2006 07:50 AM
delete profile ?? n/a Forum and Wrox.com Feedback 6 August 8th, 2003 03:24 PM





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