Error when editing content

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
8/12/2006 12:58:14 AM
Gravatar
Total Posts 8

Error when editing content

Hi Guys I am brand new to MojoPortal and I'm having an issue with getting things running properlly... I'm getting the following error when attempting to edit content... System.NullReferenceException: Object reference not set to an instance of an object. Line 128: if (!Page.IsPostBack) Line 129: { *Line 130: ViewState["UrlReferrer"] = Request.UrlReferrer.ToString(); Line 131: PopulateControls(); Line 132: } *indicates the line in question... Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] mojoPortal.Web.EditHtml.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Normal\My Documents\Visual Studio 2005\WebSites\mojoportal\Web\HtmlEdit.aspx.cs:130 System.Web.UI.Control.OnLoad(EventArgs e) +80 System.Web.UI.Control.LoadRecursive() +49 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3720 Is there something that I'm missing from my configuration? Cheers Brian
8/12/2006 4:21:09 AM
Gravatar
Total Posts 18444

Re: Error when editing content

Hi Brian,

I'm not sure why you are getting that error.
Are you using the sources from the zip download or from svn?
I assume you are using MS SQL?

Can you set a breakpoint in the page load event and step through the code and see exactly where its blowing up and which object is null? If you do this, make sure you set Default.aspx as the startup page. If you go directly to HtmlEdit.aspx there won't be an UrlReferrer. Request.UrlReferrer gets the previous page and we store it in ViewState so we can go back when editing is finished. In normal operation you should never get to the edit page except from a content page.

I do think I should modify the code  at the bottom of btnUpdate_Click and btnDelete_Click

from

SiteUtils.SetupRedirect(this, ViewState["UrlReferrer"].ToString());
return;

to

if(ViewState["UrlReferrer"] != null)
{
SiteUtils.SetupRedirect(this, ViewState["UrlReferrer"].ToString());
}
return;

just to be a little more robust, but like I say normally you don't go directly to this page so it shouldn't be null

But your error seems to be happening in PageLoad which is weird. Are you using the default skin? Any unusual configuration about your development machine?

Joe
8/12/2006 12:33:37 PM
Gravatar
Total Posts 8

Re: Error when editing content

Hi Joe Thanks for the reply... I'm using the source from the zip download (2.1.1) I'm using MySQL on the DB side - but I got this error when using SQLite as well... The main difference I think of is the Web Server - I'm using Cassini Web Server (as I'm running on XP Home)... I will attempt to get the system working in debug - something that I'm still working on and see if I can step through the code... Thanks again... Brian
8/12/2006 2:20:39 PM
Gravatar
Total Posts 8

Re: Error when editing content

Hi Joe I've since discovered that it's not just the HTMLEditContent function that seems to be having an issue - it appears to be anything that relates to adding or editing any type of content (e.g. Image Gallery, Forum posts, Adding links)... It's sounds configuration related, rather than code... Any ideas? Thanks Brian
8/12/2006 3:44:18 PM
Gravatar
Total Posts 18444

Re: Error when editing content

I've never tested with Cassini web server. I never claimed mojoPortal supported Cassini and I don't plan to offically support it but if you can identify some minor changes that won't break anything on IIS but will make it work in Cassini I'd be glad to make the changes.


Joe
8/12/2006 10:06:55 PM
kwa
Gravatar
Total Posts 23

Re: Error when editing content

I think the problem is the "Request.UrlReferrer" is null, and this statement "Request.UrlReferrer.ToString()" is trying to convert null referrence to string value which is not allowed in dotnet. The problem could not handle with this:

if(Request.UrlRefferrer != null ){

         ViewState["UrlReferrer"] = Request.UrlRefferrer.ToString();

}else{

        ViewState["UrlRefferrer"] = SiteUtils.GetRoot();

}

This is just a quick way to handle error. What I did is more than that, I removed all this ViewSate in every -*-Edit.aspx.cs and create a public property in the basePage to handle this.

Good luck.

8/15/2006 9:24:18 AM
Gravatar
Total Posts 18444

Re: Error when editing content

I should correct myself to say that I don't plan to officially support use of Cassini to run a web site, but I do plan to make the next source code release work in the Visual Studio Development Web Server (aka Cassini) for development and debugging in order to make it an easier out of the box experience for developers without having to setup IIS configuration.

Just wanted to clarify that. I've been experimenting with it and it shouldn't be too difficult to get it working.

Cheers,

Joe
8/16/2006 1:48:21 AM
Gravatar
Total Posts 8

Re: Error when editing content

Thanks Joe
That would be cool - I'm attempting to get IIS on my XP Home machine instead of struggling with URL Referrer issue...
Thanks
Brian
8/22/2006 11:44:23 PM
Gravatar
Total Posts 8

Re: Error when editing content

Hi There
Just to let you know that I've managed to resolve this issue...
It is related to Casini & Absys Web Servers (i.e. not IIS).
I've managed to get MojoPortal working with IIS and this issue is not there.
Thanks again
Brian
11/2/2006 12:42:33 PM
Gravatar
Total Posts 10

Re: Error when editing content

I'm getting the exactly same error whenever I use Cassini or IIS server. Even on mojoPortal online demos and posting this reply I got the same error. So I had to switch computer to post this reply.
In my case the problem is somewhere in my computer/browser/internet access settings. I'm tryng to find the exact cause of this problem.

And because of that in Mojo you should put that url refferer saving to, for example, try/catch block. Not every browser sends HTTP refferer headers or they may be not allowed.

Cheers :)
11/2/2006 12:56:09 PM
Gravatar
Total Posts 18444

Re: Error when editing content

Hi,

Thanks for the feedback I will add a try catch or some other logic to help avoid this. Though I suspect it is not a  widespread problem, you are right that we should do something to prevent this error and I will definitely look into it.

Thanks,

Joe
You must sign in to post in the forums. This thread is closed to new posts.