nigelstephens
asked on
Cached url with ajax version causing unhandled error with asp.net c#
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: b914df847a4e4052bc2ef31a55 a74958
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.FileLoadExceptio n
Exception message: Could not load file or assembly 'AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b 6d53e' 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.RuntimeA ssembly._n Load(Assem blyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeA ssembly.nL oad(Assemb lyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeA ssembly.In ternalLoad AssemblyNa me(Assembl yName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeA ssembly.In ternalLoad (String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly .Load(Stri ng assemblyString)
at AjaxControlToolkit.Toolkit ScriptMana ger.Script Entry.Load Assembly()
at AjaxControlToolkit.Toolkit ScriptMana ger.Deseri alizeScrip tEntries(S tring serializedScriptEntries, Boolean loaded)
at AjaxControlToolkit.Toolkit ScriptMana ger.Output CombinedSc riptFile(H ttpContext context)
at AjaxControlToolkit.Toolkit ScriptMana ger.OnInit (EventArgs e)
at System.Web.UI.Control.Init Recursive( Control namingContainer)
at System.Web.UI.Control.Init Recursive( Control namingContainer)
at System.Web.UI.Control.Init Recursive( Control namingContainer)
at System.Web.UI.Control.Init Recursive( Control namingContainer)
at System.Web.UI.Control.Init Recursive( Control namingContainer)
at System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt)
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: b914df847a4e4052bc2ef31a55
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.FileLoadExceptio
Exception message: Could not load file or assembly 'AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b
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.RuntimeA
at System.Reflection.RuntimeA
at System.Reflection.RuntimeA
at System.Reflection.RuntimeA
at System.Reflection.Assembly
at AjaxControlToolkit.Toolkit
at AjaxControlToolkit.Toolkit
at AjaxControlToolkit.Toolkit
at AjaxControlToolkit.Toolkit
at System.Web.UI.Control.Init
at System.Web.UI.Control.Init
at System.Web.UI.Control.Init
at System.Web.UI.Control.Init
at System.Web.UI.Control.Init
at System.Web.UI.Page.Process
ASKER
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).
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).
ASKER
Thanks for the suggestion but that is not the cause of the problem as this happens on the live website.
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked out a solution myself
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...