Overloading 51Degrees per request slows ASP.NET MVC to a crawl

My ASP.NET MVC 3 project slows down the scan after adding the 51Degrees mobile device discovery library. The 51Degrees log file, defined by <log logFile="~/bin/App_Data/51Log.txt" logLevel="Info" /> in the <fiftyOne> section, shows that the device library is reloaded for each request, adding a delay of 2-3 seconds for each request:

 2011-10-22T14:17:34.9863774Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1882ms 2011-10-22T14:17:50.8442844Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1820ms 2011-10-22T14:17:57.2756523Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1928ms 2011-10-22T14:18:01.0488681Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1886ms 2011-10-22T14:18:04.6790757Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1862ms 

In addition, setting <fiftyOne> <log ... logLevel="Debug"> to web.config raises the following exception at startup:

 Storage scopes cannot be created when _AppStart is executing. 

MVC 4 Update

Everything works fine if I create an empty ASP.NET MVC 4 application and add the new NuGet 51Degrees 2.0.3.2 package. As expected, the log reflects that binary data is downloaded only once, despite numerous requests (51Degrees.mobi-Lite-2012.01.05.dat).

Carefully optimistic, I copied all of my main MVC 3 project project to a new ASP.NET MVC 4 project and re-added the last 51Degrees package, but the problem persists. There must be incompatibility with one of my packages or a weird setup.

The log shows that the library is reloading for each request:

 2012-01-18T11:50:02.5026920Z - 11928 - Info - Creating provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:02.8137098Z - 11928 - Info - Created provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:07.7419917Z - 11928 - Info - Creating provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:08.0170074Z - 11928 - Info - Created provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:10.4191448Z - 11928 - Info - Creating provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:10.7251623Z - 11928 - Info - Created provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 

The delay is much less than the XML data file (300 ms versus 3000 ms), but it still causes a noticeable delay.

The files of the two 51Degrees.mobi.config projects are identical, and in my web.config this is the module I downloaded:

 <modules> <remove name="Detector"/> <add name="Detector" type="FiftyOne.Foundation.Mobile.Detection.DetectorModule, FiftyOne.Foundation"/> </modules> 

What can cause a 51Degrees library to reload on each request?

+7
source share
2 answers

This is because the log file is placed in the bin folder. Whenever something changes in the bin folder, the workflow restarts. Move the log file to the ~ / App_Data folder and you will find that the problem is resolved. Thank you for using 51Degrees.mobi .

+7
source

I grabbed the CodePlex demo MVC3MobileDect application. I ran it using ASP.NET Web Development Server and IIS Express and did not find any problems that you encounter when the library restarts all devices for every request to the web server.

Also, the demo project did not include the modification of the BrowserCapabilitiesProvider in Application_Start (but it still works, even when I added it).

At this point, assuming you are using an open source version, I would suggest grabbing the source code for the Foundation assemblies and starting by setting a breakpoint in

\Foundation\Mobile\Detection\Wurfl\Provider.cs (probably in the InitWurflFiles method).

There might be something in the call stack that helps you better understand what is going on.

Or compare the configuration of the demo project with your web application.

0
source

All Articles