How to Remove Telerik.Web.UI.WebResource.axd js

Posted by Community Admin on 04-Aug-2018 04:11

How to Remove Telerik.Web.UI.WebResource.axd js

All Replies

Posted by Community Admin on 31-Jul-2014 00:00

Hi guys,

I'm using sitefinity 6.3, Windows 8 machine. In my web sites it will auto add Telerik.Web.UI.WebResource.axd Javascript file. How can I remove it  ? 

Regards

Minco 


Posted by Community Admin on 31-Jul-2014 00:00

 My web sites will auto add  two files.   In my page template  I have  assigned my custom Theme

Please see the information below.

<link href="/Telerik.Web.UI.WebResource.axd?compress=0&_TSM_CombinedScripts_=%3b%3bTelerik.Sitefinity.Resources%2c+Version%3d6.3.5000.0%2c+Culture%3dneutral%2c+PublicKeyToken%3dnull%3aen%3afc2ebef4-f9ad-4295-94c5-72ca5c30cdcc%3a4a0e9096%3a68ef0189" type="text/css"rel="stylesheet" />
 
 
<script src="/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl03_TSM&compress=0&_TSM_CombinedScripts_=%3b%3bTelerik.Sitefinity.Resources%2c+Version%3d6.3.5000.0%2c+Culture%3dneutral%2c+PublicKeyToken%3dnull%3aen%3afc2ebef4-f9ad-4295-94c5-72ca5c30cdcc%3a9324ecca%3a472a0b31%3a261b43f4%3acaa640fd%3bTelerik.Sitefinity%2c+Version%3d6.3.5000.0%2c+Culture%3dneutral%2c+PublicKeyToken%3db28c218413bdf563%3aen%3aa2fff8da-9d1a-4072-a015-7a0a90a434ae%3a89799d3c" type="text/javascript"></script>

Posted by Community Admin on 01-Aug-2014 00:00

help ,help ....

Posted by Community Admin on 01-Aug-2014 00:00

A moment ago , I found this remove Telerik.Web.UI.WebResource.axd .   I have assigned theme  for page template, but it doesn't ok,  the styles also hard-coded into this file telerik.web.ui.webresource.axd  and auto linked telerik.web.ui.webresource.axd 
 js  file.

Who can tell me how to remove it ?  

Posted by Community Admin on 01-Aug-2014 00:00

Hi Minco,

You can override Render event in your master page and remove any unwanted nodes.

protected override void Render(HtmlTextWriter writer)
       
            var tw = new StringWriter();
            var htw = new HtmlTextWriter(tw);
            base.Render(htw);
            var pageSource = tw.ToString();

            pageSource = RemoveScripts(pageSource);

            writer.Write(pageSource);
       

 

private string RemoveScripts(string html)
       
            var htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(html);

            if (htmlDoc.DocumentNode == null)
                return string.Empty;

            var scriptNodes = htmlDoc.DocumentNode.SelectNodes("//script")
                .Where(i =>
                    i.GetAttributeValue("src", string.Empty).Contains("WebResource.axd") ||
                    string.IsNullOrEmpty(i.GetAttributeValue("src", string.Empty))
                    );
            var linkNodes = htmlDoc.DocumentNode.SelectNodes("//link")
                .Where(i =>
                    i.GetAttributeValue("href", string.Empty).Contains("WebResource.axd") ||
                    string.IsNullOrEmpty(i.GetAttributeValue("href", string.Empty))
                    );

            foreach (var node in scriptNodes)
           
                node.ParentNode.RemoveChild(node);
           
            foreach (var node in linkNodes)
           
                node.ParentNode.RemoveChild(node);
           

            return htmlDoc.DocumentNode.OuterHtml;
       

 Don't forget to include following namespaces.

using HtmlAgilityPack;
using System.Text.RegularExpressions;
using System.IO;
using System.Linq;

Hope it helps.

Thanks

Posted by Community Admin on 01-Aug-2014 00:00

Hi  saad ,

In sitefinity master page don't have  CodeBehind file .  I can't write it in there.

 see the atach file .

Regards

Minco 

 

Posted by Community Admin on 01-Aug-2014 00:00

Hi Minco,

You will have to use your .master file to inherit your page template from. This way you don't loose any functionality but get access to the code behind.

Posted by Community Admin on 05-Aug-2014 00:00

Hi  Saad  ,

Thank you very much.  It's ok now.   But I still want to know  how  to solve it by Sitefinity Team. 

This thread is closed