NullReferenceException in DotNetNuke 7 FriendlyUrlProvider

A recent client was having trouble with their DotNetNuke site search following an upgrade to version 7.  For some queries, the search function would return no results found even when there were a number of modules whose content it matched.  For others it would work just fine.  Deleting and re-indexing the search content still returned the same result.

The Event Viewer for the portal contained the following error:

System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Entities.Urls.BasicFriendlyUrlProvider.FriendlyUrl(TabInfo tab, String path, String pageName, PortalSettings settings) at DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider.FriendlyUrl(TabInfo tab, String path, String pageName, PortalSettings settings) at DotNetNuke.Common.Globals.NavigateURL(Int32 tabID, Boolean isSuperTab, PortalSettings settings, String controlKey, String language, String pageName, String[] additionalParameters) at DotNetNuke.Services.Search.Controllers.ModuleResultController.GetDocUrl(SearchResult searchResult) at DotNetNuke.Services.Search.Controllers.SearchControllerImpl.GetSecurityTrimmedResults(SearchQuery searchQuery, LuceneQuery luceneQuery) at DotNetNuke.Services.Search.Controllers.SearchControllerImpl.GetResults(SearchQuery searchQuery) at DotNetNuke.Services.Search.Controllers.SearchControllerImpl.SiteSearch(SearchQuery searchQuery) at DotNetNuke.Web.InternalServices.SearchServiceController.GetGroupedDetailViews(SearchQuery searchQuery, Int32& totalHits, Boolean& more) at DotNetNuke.Web.InternalServices.SearchServiceController.Search(String search, String culture, Int32 pageIndex, Int32 pageSize, Int32 sortOption)

I downloaded the DotNetNuke source package and was able to determine that the error was caused by a null value being passed to the friendly URL provider for the portal alias associated with the site.

The fix was simple.  There was no default portal alias set for that site.  I updated the portal alias record in Site Settings under the Admin menu and I was able to see the missing search results.

It is possible that after the upgrade there was something with the portal aliases that was saved improperly and it just needed a refresh.  Nonetheless, I wanted to provide my steps to fix the problem in case it helps.

Thanks for reading!  Leave a comment and let me know if this fix works for your site.