Based on the error message you provided, it appears that the issue may not necessarily be related to the <anonymousidentification> tag in your web.config file, but rather to the Request.Anonymous field being null.
Here are a few things you can try to troubleshoot the issue:
Ensure that the <anonymousidentification> tag is present in the correct section of your web.config file. It should be located within the <system.web> section, like so:
<configuration>
<system.web>
<anonymousIdentification enabled="true" cookieless="UseCookies" cookieName=".ASPXANONYMOUS" cookieTimeout="4320" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" />
</system.web>
</configuration>
When you've validated it is placed correctly on your production environment, make sure that anonymous authentication is enabled in IIS on your production server.
To do this, open IIS Manager, select your website, and click on the "Authentication" feature. Make sure that "Anonymous Authentication" is enabled.
If you've confirmed that, you can check the version of ASP.NET running on your production server. Make sure that it is compatible with your MVC 5 project.
Check if your code is trying to access the Request.Anonymous field
before the request has been authenticated. If this is the case, you need to make sure that the request is authenticated before trying to access the Request.Anonymous field. You can use the following code to check if the request is authenticated before accessing the Request.Anonymous field:
if (HttpContext.Current.Request.IsAuthenticated)
{
}
else
{
}
Lastly, you could try adding some logging or debugging statements to your code to identify the root cause of the issue. Like:
Debug.WriteLine("Request.IsAuthenticated: " + HttpContext.Current.Request.IsAuthenticated);
Debug.WriteLine("Request.Anonymous: " + HttpContext.Current.Request.Anonymous);
Hope this helps you to debug your situation.