Including the original script name when using asp.net scriptmanager / scriptresource.axd

StackOverflow https://stackoverflow.com/questions/14397983

  •  16-01-2022
  •  | 
  •  

Question

I am working on an asp.net web app with typically 30 different ScriptManager scripts referenced (as ScriptResource.axd?d=[encrypted-script-name] )

This makes it difficult to find the right script when debugging in e.g. firebug. It would be great if there was some way the original filename could be appended to the script url in debug mode, e.g.

ScriptResource.axd?d=[encrypted-script-name]&orig=MyScript.js

(I realise that this should be debug only!)

Is there a way to do it?

Was it helpful?

Solution

One of the way could be not to use ScriptManager to serve the scripts in say debug mode - for example

protected void ScriptManager_PreRender(object sender, EventArgs e)
{
  // include normal script references in debug mode, SM is script manager instance name
  if (SM.IsDebuggingEnabled)
  {
    foreach (var script in SM.Scripts)
    {
       // based on script properties, use RegisterClientScriptResource 
       // or RegisterClientScriptInclude methods of Page.ClientScript
    }
    SM.Scripts.Clear();
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top