1

I am relying on @Request.Browser.IsMobileDevice to differentiate the visitors to an ASP .NET MVC website.

I am using 51 Degrees library. However when browsing some images from mobile devices, I have the error 414 (request-uri too long). On the PC, this is not happening, only on the mobile.

The stack is showing PathTooLongException at :

   à System.IO.PathHelper.GetFullPathName()
   à System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   à System.IO.Path.GetFullPathInternal(String path)
   à System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
   à System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
   à System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   à System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
   à System.Web.InternalSecurityPermissions.PathDiscovery(String path)
   à System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping)
   à System.Web.HttpServerUtility.MapPath(String path)
   à FiftyOne.Foundation.Mobile.Detection.Feature.ImageOptimiser.OptimisedImageResponse(HttpContext context)
   à FiftyOne.Foundation.Mobile.Detection.DetectorModule.OnPostAuthorizeRequest(Object sender, EventArgs e)
   à System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   à System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

It seems FiftyOne is in this stack. And when I uninstall 51Degrees, it resumes working. However I need 51Degrees to keep IsMobileDevice compatible with the current devices.

Is there any parameter I am missing ? 51degrees is version .NET 3.1.9.3

Yahia
  • 805
  • 7
  • 25
  • Seems like the `ImageOptimiser.OptimisedImageResponse` is attempting to map a virtual path to a physical disk path. The max length of a full file path is only 260 characters. My guess would be the library has managed to create a path that is just too long for the system to deal with. – Steven V Feb 12 '15 at 14:01
  • I just ran into this issue. Did you get this working? – Perry Jun 05 '15 at 20:08

2 Answers2

1

I ran into this same issue just a few days ago. We have been using the 51Degrees solution for a number of years but are just now running into the 414 issue on mobile devices.

I ended up using "The official WURFL API for .NET". Easy to implement and provides all the functionality we need to read from the WURFL data repository. And now I no longer get the 414 errors.

Perry
  • 611
  • 6
  • 15
0

If you ever find yourself in similar situation, you can:

  1. Go to 51Degrees.config file
  2. Open it
  3. Scroll down until you find imageOptimisation section
  4. Set enabled to false
  5. Save and restart application

Just another way to solve the 414 issue.

Jaroslaw Stadnicki
  • 1,178
  • 1
  • 8
  • 17