Enhancements and Bugs Forum


Object reference not set to an instance of an object

 
I Publish the MvcCms 2.0 source successful. But deploy on iis6 and view in browser it occurred an error
File in : MvcCms 2.0\MvcCms.Web\MvcCms.Web\Controllers\HomeController.cs Line: 46
Source Error:
Line 44: {
Line 45: currentPortal = cacheService.GetCurrentPortal();
Line 46: ViewData"SiteName" = _currentPortal.DisplayName;
Line 47: ViewData"DefaultLangID" = _currentPortal.DefaultLanguage.LanguageID;
Line 48: IDictionary<string, object> routeTokens = RouteData.DataTokens;
error message: Object reference not set to an instance of an object
1 years 7 months 1 days ago by sgcms

Replies

Reply posted by jon 1 years 7 months 1 days ago View Branch And Reply
Most likely the problem there is that you need to edit the portal urlauthority to the url you are using in iis.

What is the url in the browser when you get the message and I can give you the sql to update your portals table. I'll also need the portal id of the portal you want to show up from your portals table.

There are quite a few hoops to jump through to get 2.0 running on iis6, the wild-card mapping and installation and enabling of .net 4.

MvcCms determines what portal to show by matching the urlauthority or domain name from the request to the matching urlauthority in the portals table. If no match is found then you get that error.

I suppose some code there to take the user to a page explaining this might be a good way to handle that error. I added this as an enhancement to 2.0 here http://www.mvccms.com/wiki/mvccms-20

edit-- I guess is being asked here also http://mvccms.codeplex.com/workitem/5731
Reply posted by sgcms 1 years 7 months ago View Branch And Reply
update the database like this:
update Portals
set URLAuthority = 'www.*.com'
where Name='Default'
select * from portals
Make a install wizard will more friendly
Reply posted by jon 1 years 7 months ago View Branch And Reply
I would love to have a great install wizard but I have limited resources and no one has contributed one yet. Since this app is geared toward developers it just isn't on the priority list right now.

Once you know how to set an initial portal with the sql query it is pretty easy to do. There is a sql script included in the database folder showing the equivalent of your query above called DBBackup\SetFirstPortalURL.sql and the readme does explain what to do.

But again if you are looking for a CMS that is finished out for non technical users this one probably isn't right for you now. Perhaps in the 3.0 version this will be done.

http://lmgtfy.com/?q=mvccms+sql+set+initial+portal

But no I understand the error there is getting to be a common thing. I think I will at least catch the error there and redirect to a page that tells how to check that a url is matching between the request and the portals table for the 2.0 version.