Jul 20, 2011 at 7:47 AM
Edited Jul 20, 2011 at 7:51 AM
When analytics is turned on adwords, google adds a variable to the url, for example: www.mywebsite.com/?gclid=abcd1234
This is causing an error on the homepage:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 193: var currentPage = PageIndex();
Line 195: var visiblePosts = this.Posts.FindAll(p => p.IsVisible);
Line 196: var postCnt = visiblePosts.Count;
Source File: d:\home\Default\website.com\BlogEngine.Web\App_Code\Controls\PostPager.cs Line: 195
[NullReferenceException: Object reference not set to an instance of an object.]
App_Code.Controls.PostPager.PagerTag() in d:\home\Default\website.com\BlogEngine.Web\App_Code\Controls\PostPager.cs:195
App_Code.Controls.PostPager.Render(HtmlTextWriter writer) in d:\home\Default\website.com\BlogEngine.Web\App_Code\Controls\PostPager.cs:43
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
Can someone tell me the best work around (the client needs analytics so i can't turn it off) - i'm using BlogEngine.NET 220.127.116.11
anyone any ideas?
thanks in advance
Jul 27, 2011 at 11:22 AM
This was a bug in the post page control that was fixed at one point.
A good version of this file is
here. It's PostPager.cs file in the App_Code\Controls folder that needs to be updated. There's actually only one change which is to add the following highlighted line at around line 186.
private string PagerTag()
if (this.Posts == null) return "";
..... existing code ......
This should get past the error. But you probably also need to modify default.aspx.cs in the root folder. On or around line 44 is the following. You would want to add the part highlighted in yellow ... this would allow the gclid query string
parameter (intentional line breaks added):
else if (
Request.QueryString.Count == 0 ||