Chapter 16 Error? - Missing RTrim
Sorry if this has been covered before... or if I've simply done something wrong, but I couldn't get the code on pages 580 & 581 to work. In other words, my Website would not perform the way you told us to expect given your example code. After much trial and error, I found the problem. I *think* it came down to this:
photoAlbumOwner requires an RTrim performed on it before it can be accurately compared to User.Identity.Name.
I think I discovered the reason for this: You've told us to establish the UserName field in the PhotoAlbum Table as nvarchar(256) ... (see p. 578).
I discovered that the photoAlbumOwner string in your example would *begin* with the proper name... but that string would be padded with spaces *after* the name. On the other hand, "User.Identity.Name" contained only the 'name' itself; without any trailing spaces. Because of this, the only way for your pages 580 & 581 code to work, I had to apply an RTrim to photoAlbumOwner.
Once I changed the appropriate code to things like:
User.Identity.Name = RTrim(photoAlbumOwner) and
User.Identity.Name <> RTrim(photoAlbumOwner)
...I found my Website was navigating in the way you told us it should.
Am I being crazy here? I'm thinking that since this is not in the Errata, I'm thinking I must have done something wrong.
Have I? Thanks in advance.
|