This project is read-only.

Caching of Post properties

Topics: ASP.NET 2.0, Business Logic Layer
Jun 25, 2008 at 4:19 AM
I'm going to start by saying that I've modified the source of version 1.3.1.  My instance is using the MSSql Blog Provider.  I'm not a seasoned .Net developer, but I can make my way around the project pretty well.  I've broken something.

Before I started using Blog Engine, I established and used the SQL Membership/User/Profile classes available in .Net 2 on our original site.  Additionally, I was able to enable these providers in Blog Engine and log in cross-site.  The problem is, long ago, I set things up so that a person's e-mail address will be their User Name.  The User Name is being populated with the user's e-mail address behind the scenes.  I wasn't thinking ahead, and now I don't wish for these e-mail addresses to be exposed to the public.

So I've created a profile property called ScreenName that I want to use for this purpose.  I've actually done a pretty good job of going through and changing the places where the e-mail address displays, and replaced it with ScreenName.

It seems now, though, that something is cached somewhere.  This may be related to my changes, but I'm hoping someone recognizes this behavior and can point me in the right direction: when I write a new post, the author's name (the ScreenName profile property) appears blank.  Additionally, if I edit a post (as an admin) and change the author of a post, the change does not reflect when viewing the post even though the data behind the scenes is properly still shows the old author.  To shake things loose, all I have to do is recompile the project or re-save web.config and refresh the page I'm on and everything displays the ScreenName property as I intended.

To avoid wordiness, I guess I'm wondering if anyone can suggest where I might start looking to start resolving this problem?  I can provide any details you like, just let me know.  And thanks in advance for any help you might be able to provide.

Jun 26, 2008 at 1:24 AM
Hi Matt,
I'm not sure the following explanation would help or not, but let's just discuss it.

About the caching, it's correct that BE.N caches all things including the posts. However, when you create a new post or edit an existing one, BE.N will edit the cache directly before it is stored in the persistence state. So, the affected post will always contain the newest content.

In the Add_Entry.aspx admin page, the author's name of a post is retrieved from the Author's dropdownlist, which is populated from the Membership provider. Regardless of the provider (original or custom), BE.N will take the UserName property to be used as author's name of the post. I think if you changed this behavior (for example changing to ScreenName instead of UserName), you'd have to modify some codes in this page.

Agus Suhanto
Jun 26, 2008 at 3:41 AM
Agus - Thank you very much for the response.  And of  course, for all the hard work.

I tried to not disturb BE.N's use of UserName in the Author field of the database record.  So to that end, I have not touched the Add_entry.aspx(.cs) files.  I did, however, create a property in BlogEngine.Core.Post called Author_ScreenName which is subsequently populated via BlogEngine.Core.MSSQLBlogProvider.SelectPost.  So I think what I'm gathering is that, in Add_entry.aspx.cs, I need to populate this property as well which will update the cache and cause the name to appear on adds and updates.  This would explain why rebuilding the project fixed this, because it propbably forced the cache to be rebuilt, and the Author_ScreenName property came along with that.

Thanks again for helping me through this.  I think I talked it out.  Gonna go try it now!