Post not found problem

Topics: Business Logic Layer
Apr 29, 2011 at 11:49 AM

hi

i use dotnetblogengine ver 2.0.0.36 with sqlserver provider on IIS 7

about 3 month every things ok and not any problem, all post successfuly added and show on posts section

after about a month distance write new post and add sucessfuly to DB but when go to the post i saw redirect to resource not found page,

i refresh some time and see the post some times showing and some times redirect to resource not found page,

when i go to admin area and refresh post list i see some times post apear and some time disapear in the list,

i check DB and see post added peoperly,

i check logger file and get no error,

i dont know what happen, please help me,

thanks,

Apr 29, 2011 at 2:23 PM

i think this is bug

when i want edit any new post, i go to edit post, post load properly to ckeditor but when click to save button to save change, i get "Post to Edit was not found." error,

Apr 30, 2011 at 7:00 AM

hi

i remove some code in Post class related caching then every thing work fine,

        public static List<Post> Posts
        {
            get
            {
                //if (posts == null)
                //{
                    lock (SyncRoot)
                    {
                        //if (posts == null)
                        //{
                            posts = BlogService.FillPosts().Where(p => p.IsDeleted == false).ToList();
                            posts.TrimExcess();
                            AddRelations();
                        //}
                    }
                //}

                return posts;
            }
        }

each time load all of post from SqlServer,

but this is wrong way but i dont know how resolve this problem

please help me,

thanks

Apr 30, 2011 at 10:05 AM

i save posts in cach with this way : HttpContext.Current.Cache["Posts"]

and every thing work fine;

can any body describe differance between posts.TrimExcess(); and HttpContext.Current.Cache["Posts"] ???

and why posts.TrimExcess(); not work properly in my host?

thanks,

Coordinator
Apr 30, 2011 at 11:25 AM

posts.TrimExcess(); shouldn't cause any problems ... it just removes extra allocated space in "posts" that is not being used.

You mentioned ckeditor ... BE uses tinyMCE, unless you changed it to ckeditor?

Do your posts appear correctly on the front end of the site (any problems on the front end)?  Is it just when editing a post that you get the error message "Post to edit was not found"?

BE stores posts in the static "posts" field ... it doesn't use HttpContext.Current.Cache["Posts"].  The posts in the static "posts" field will stay in memory the entire time the BE application is running.  If you use HttpContext.Current.Cache instead, the posts might exit cache if the website is low on memory and you would need to re-load the posts if they leave cache.

The static "posts" is the default way that BE stores the posts, and it works on all BE websites I'm aware of.  So I am doubtful there is any problem with that piece of code.

...... is your website hosted at a webhost?  Have they made any recent changes?  The problems you describe sound like the type of problems that happen when BE is running in a cloud environment, web farm or load balancing environment.  If there is more than one machine handling your website, each machine will have its own separate list of posts in memory.  If a post changes on one server, the other servers do not know of this change and continue working with an older set of posts.  Not sure if your site is running in this type of environment ... or if the webhost has made any changes such as this ... i.e. changing the architecture of the server where your site is running.

Apr 30, 2011 at 4:27 PM

hi

thanks BenAmada

this is my mistake about TrimExcess,

i use tinyMCE, excuse me for these mistake,

this is IP of my server that blogs hosted: http://67.212.76.235/

my problem is very same that you describe about cloud environment problem,

but i dont know how check this attribute in server,

this problem is in the fornt post and admin area same,

i think 2 month ago server memory is update with new bigger one,

thanks again BenAmada

Coordinator
May 4, 2011 at 1:26 PM

The best option at this point would be to send the web host a question asking them about their architecture.

You would want to find out if your web site is setup traditionally with a single machine serving web traffic.  Or is it setup with some type of load balancing, cloud/virtualized environment, web farm, or some type of architecture where multiple machines/processes are serving web traffic.

May 5, 2011 at 6:22 AM

hi

thanks BenAmada

i added some need column to post table in database, This change could be causing this problem?

May 5, 2011 at 6:39 AM

full describtion of my post tabble changed?

i add DisplayOrder Field to post table in sqlserver database with zero value default and post object and post json object, and edit post administration in admin area, every thing seems ok,

i also edit admin.js file and add some function to sorting by DisplayOrder,

since i used metaweblog api to adding any post these problems appeared

i dont know this change could be causing this problem or not?

May 5, 2011 at 9:30 AM

i asked your question from server support,

they say my server is single machine not load balancing, cloud/virtualized environment,

problem not fixed with changing to HttpContext.Current.Cache["Posts"]

but when i upload BlogEngine.Core dll file again every post work fine but when i add new one again this problem appear

please help me,

Coordinator
May 5, 2011 at 1:05 PM

I wouldn't use HttpContext.Current.Cache["Posts"].  I would recommend sticking with the original BE code for that (the code you posted above in the 3rd message of this thread).

After adding a new post, I would go to the archive page (archive.aspx) and see if the post appears there.  The archive page shows all the posts that are loaded in memory.  My guess is that if you are are getting "post not found" errors when you try to edit a post, then you probably won't see that post on the archive page.  But checking archive.aspx will still be a good test.

You might want to see this discussion.  There's a method in Post called Reload, that can be called via Post.Reload();  You can use Post.Reload() to reload the posts in memory ... so you don't have to re-upload BlogEngine.Core.dll or manually modify your web.config file etc.  Normally Post.Reload() isn't necessary.  But if for some reason posts are not appearing on your blog, you can try using this.  If the only time posts are not appearing is right after you create a new post, then you might want to create a button in the admin area (control panel) that you can click that will call Post.Reload().  After you create a new post, you could click this button.