This project has moved. For the latest updates, please go here.

"Value cannot be null" error (using AD web.config)

Sep 23, 2014 at 3:21 PM
Any ideas on the following? Am seeing an error (see below) when trying to browse the web app after installation. I've replaced Web.config with the contents of ADWeb.config and configured the required appSettings based on your config guide.

Server Error in '/' Application.

Value cannot be null.
Parameter name: value

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.ArgumentNullException: Value cannot be null.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ArgumentNullException: Value cannot be null.
Parameter name: value]
System.Runtime.Caching.MemoryCacheEntry..ctor(String key, Object value, DateTimeOffset absExp, TimeSpan slidingExp, CacheItemPriority priority, Collection`1 dependencies, CacheEntryRemovedCallback removedCallback, MemoryCache cache) +89042
System.Runtime.Caching.MemoryCache.AddOrGetExistingInternal(String key, Object value, CacheItemPolicy policy) +771
System.Runtime.Caching.ObjectCache.Add(String key, Object value, CacheItemPolicy policy, String regionName) +25
TicketDesk.Domain.Services.AdSecurityCacheService.SetCache(ObjectCache cache, String key, Object value, CacheItemPolicy policy) +49
TicketDesk.Domain.Services.AdSecurityCacheService.GetRoleMembers(String groupName) +491
TicketDesk.Domain.Repositories.AdSecurityRepository.IsUserInRoleName(String userName, String roleName) +61
TicketDesk.Domain.Services.SecurityService.IsInValidTdUserRole() +94
ASP.views_shared_quickseach_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) +171
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +85
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5363

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
Coordinator
Sep 24, 2014 at 2:34 AM
This kind of error is almost always a configuration issue in the end.

The problem area - In this section of code, TicketDesk is trying to query it's local cache of AD data. This data is read from AD by a background process, and stored in the database. This is necessary because quering AD directly on-demand can take a REALLY long time, and the website will respond very slowly if it has to wait on AD for every user display name or email address it needs to know about before it can render the requested page.

The specific problem - The code is querying the SQL database for cached AD information. In this case, it is looking for the list of all users who belong to an AD group. The query is not failing, but it is returning zero users. The code doesn't correctly handle a case where one of the AD groups doesn't contain any user accounts.

Things to check:
  1. In AD, make sure there is at least one user account in each of the AD groups you've configured for use with TicketDesk (specified in web.config)
  2. In web.config, make sure the three AD groups being mapped to TicketDesk are correct, that the group name is spelled correctly, and that there aren't any missing or extra whitespace characters in the group names.
  3. Make sure that the credentials in web.config which the application uses to query AD are correct.
Additional things to consider:

The AD cache in the database is empty when you first start the application up. It is populated by a background process. It can take several minutes for it to complete all the queries it needs in order to build the cache. The more users in your AD groups, the longer it will take. So, fire up the web site, and visit the home page in the browser. Then don't do anything else for a while. Give it time to run and see if it can finish building the AD user information cache. Once the cache is populated the first time, you shouldn't see this problem again on future startups

.
Marked as answer by andyste1 on 9/24/2014 at 12:23 AM
Sep 24, 2014 at 7:22 AM
Many apologies. Yes, stupid typo.