Solved

Cached url with ajax version causing unhandled error with asp.net c#

Posted on 2013-01-19
7
828 Views
Last Modified: 2013-01-26
I have a .net 4 website on IIS7 and use Ajaxcontrol toolkit. Whenever I upgrade to a newer version an ajaxcontrol toolkit, I have months when a search engine uses cached urls with the ajax version in.  The information is contained in the url query string and because the information contains an old dll version for ajax which is not available it causes an unhandled error. I would like to
1. stop this form of url if possible but dont know how.
2. handle the error and provide a 301 redirect to the correct url (less the query string)

You might need to ask me a few questions here so we can get to the route of the problem.
The current version of the Ajax tool kit Im using is 4.1.60919
This page is my example.
http://www.printer-ink-toner.co.uk/pc/brother-mfc74200-drum

Here is an example of the error.

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 1/19/2013 5:50:46 AM
Event time (UTC): 1/19/2013 5:50:46 AM
Event ID: b914df847a4e4052bc2ef31a55a74958
Event sequence: 6905
Event occurrence: 52
Event detail code: 0

Application information:
    Application domain: xxxx
    Trust level: Full
    Application Virtual Path: /
    Application Path: xxxx
    Machine name: xxxx

Process information:
    Process ID: 51616
    Process name: w3wp.exe
    Account name: xxxxx

Exception information:
    Exception type: System.IO.FileLoadException
    Exception message: Could not load file or assembly 'AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Request information:
    Request URL: http://www.printer-ink-toner.co.uk/pc/brother-mfc74200-drum?_TSM_HiddenField_=ctl00_MainContent_ToolkitScriptManager1_HiddenField&_TSM_CombinedScripts_=%3B%3BAjaxControlToolkit%2C+Version%3D4.1.51116.0%2C+Culture%3Dneutral%2C+PublicKeyToken%3D28f01b0e84b6d53e%3Aen-US%3A07ead49c-3169-4e2b-b447-bacc452e967a%3Ade1feab2%3Af9cec9bc%3Aab09e3fe%3Af2c8e708%3A87104b7c
    Request path: /pc/brother-mfc74200-drum
    User host address: 66.249.78.117
    User:
    Is authenticated: False
    Authentication Type:
    Thread account name: xxxxx

Thread information:
    Thread ID: 9
    Thread account name: xxxxx
    Is impersonating: False
    Stack trace:    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at AjaxControlToolkit.ToolkitScriptManager.ScriptEntry.LoadAssembly()
   at AjaxControlToolkit.ToolkitScriptManager.DeserializeScriptEntries(String serializedScriptEntries, Boolean loaded)
   at AjaxControlToolkit.ToolkitScriptManager.OutputCombinedScriptFile(HttpContext context)
   at AjaxControlToolkit.ToolkitScriptManager.OnInit(EventArgs e)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
0
Comment
Question by:nigelstephens
  • 4
  • 3
7 Comments
 
LVL 23

Expert Comment

by:Roopesh Reddy
Comment Utility
Hi,

I suggest you to remove all the references of AjaxControlTookit and install using NuGet -

http://roopeshreddy.wordpress.com/2012/10/07/installingconfiguring-ajaxcontroltoolkit-through-nuget/

seems like AjaxControlToolKit reference problem!

Hope it helps u...
0
 

Author Comment

by:nigelstephens
Comment Utility
I have already uninstalled and installed with NuGet.
I dont think this is caused by Ajax installation references not being correct. Something to do with combining of scripts as in the url concerned a value for "CombinedScripts" is passed in the query string parameters.
 The error is being generated at the early point where the Toolkitscript manager is going to combine scripts. It is then trying to get the incorrect assembly reference(old version of ajaxcontrol toolkit). Is it possible to try and trap this error by creating an error handler and binding it to this code that runs. I beleive it is before the main pipeline begins but I do not fully understand this.

This might help
http://blogs.msdn.com/b/delay/archive/2007/06/11/script-combining-made-easy-overview-of-the-ajax-control-toolkit-s-toolkitscriptmanager.aspx

How do scripts actually get combined? [Technical]
 
Script combining is a two-stage process.
 
The first stage takes place during the normal ASP.NET page lifecycle when ToolkitScriptManager overrides ScriptManager's OnLoad method to initialize its state and its OnResolveScriptReference method to find out when script references are being resolved. The initialization code in OnLoad consists of adding a HiddenField to the page and using it to track which scripts have already been loaded by the browser. The handling of OnResolveScriptReferences is a little more involved: the script reference is checked for combinability (i.e., does the assembly's ScriptCombine attribute allow the script to take part in script combining) and the script reference is changed to point to the URL of a combined script file. In this manner, all scripts that are part of the same combined script file get the same URL and the ScriptManager class outputs that URL to the page exactly once. Notably, because scripts may have a strict ordering, the presence of an uncombinable script in the middle of combinable scripts will result in two combined script files being generated (the first consisting of the scripts coming before the uncombinable script and the second consisting of the scripts after it).
0
 
LVL 23

Expert Comment

by:Roopesh Reddy
Comment Utility
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:nigelstephens
Comment Utility
Thanks for the suggestion but that is not the cause of the problem as this happens on the live website.
0
 
LVL 23

Expert Comment

by:Roopesh Reddy
Comment Utility
Hi,

I tried accessing this link - http://www.printer-ink-toner.co.uk/pc/brother-mfc74200-drum and seems to be working fine!

Is there any scenario, where i can replicate the issue?
0
 

Accepted Solution

by:
nigelstephens earned 0 total points
Comment Utility
I have managed to place a fix in place. I put some code on the error.apx page to read the forwarded url of the problem page and if it had my products location then I do a 301 redirect to the correct location. It is not a nice a fix as I was looking for but it will do for now. Thanks for your efforts!
0
 

Author Closing Comment

by:nigelstephens
Comment Utility
Worked out a solution myself
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now