This project has moved and is read-only. For the latest updates, please go here.
2

Resolved

ArgumentNullException when connecting to the WCF service hosted with ASP.NET MVC 4 application

description

Got this exception trying to connect to the WCF service inside the ASP.NET MVC 4 application:

System.ArgumentNullException: Value cannot be null.
Parameter name: stringToUnescape
at System.Uri.UnescapeDataString(String stringToUnescape)
at FiftyOne.Foundation.Mobile.Detection.WebProvider.GetRequiredHeaders(HttpRequest request)
at FiftyOne.Foundation.Mobile.Detection.WebProvider.GetResults(HttpRequest request)
at FiftyOne.Foundation.Mobile.Detection.MobileCapabilitiesProvider.GetBrowserCapabilities(HttpRequest request)
at System.Web.Configuration.HttpCapabilitiesBase.GetBrowserCapabilities(HttpRequest request)
at System.Web.HttpRequest.get_Browser()
at System.Web.Security.CookielessHelperClass.UseCookieless(HttpContext context, Boolean doRedirect, HttpCookieMode cookieMode)
at System.Web.Security.FormsAuthenticationModule.ExtractTicketFromCookie(HttpContext context, String name, Boolean& cookielessTicket)
at System.Web.Security.FormsAuthenticationModule.OnAuthenticate(FormsAuthenticationEventArgs e)
at System.Web.Security.FormsAuthenticationModule.OnEnter(Object source, EventArgs eventArgs)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Request parameters:
Http method: POST
User agent: <empty>
Content encoding: System.Text.UTF8Encoding
Content type: application/soap+xml; charset=utf-8

Version of the FiftyOne.Foundation.dll is 3.1.8.1

comments

weases wrote Nov 3, 2014 at 8:30 AM

We are facing the exact same problem with version 3.1.8.1. It is caused by requests that do not contain an user agent header.

This worked with older versions though, as the user agent header was null checked in FiftyOne.Foundation.Mobile.Detection.WebProvider.GetRequiredHeaders(HttpRequest request) before calling Uri.UnescapeDataString(request.UserAgent).Replace('+', ' ');

This is not the case anymore with 3.1.8.1. Is this just an oversight or is it intended behavior?

iftikhar51 wrote Jun 11, 2015 at 8:10 PM

This was an issue with version 3.1.8.1. It has been fixed in later version.