Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 745799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:37:31+00:00 2026-05-14T09:37:31+00:00

Currently I have some legacy ASP.NET 2.0 code that uses the ASP Xml web

  • 0

Currently I have some legacy ASP.NET 2.0 code that uses the ASP Xml web control like this:

<asp:Xml ID="XmlResult" runat="server" />

This is used to perform an XSLT transformation in c# code-behind like this:

XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath("~/xslt/MyXsltFile.xslt"));
XmlResult.Transform = xslt;
XmlResult.TransformArgumentList = xslArgs; // these are created elsewhere

XmlResult.XPathNavigator = xd.CreateNavigator(); // xd is an XmlDocument()

The problem is that the ASP XML control expects an XltTransform object and this is deprecated (marked as obsolete) as from NET 2.0:

“The XslTransform class is obsolete in
the Microsoft .NET Framework version
2.0. The XslCompiledTransform class is the new XSLT processor.”

However, I can’t seem to figure out how to replace this to use an XslCompiledTransform object. Obviously you can just give XmlResult.Transform property an XslCompiledTransoform object as this won’t work. So presumably will have to replace the ASP Xml control with something else? A Literal? A Placeholder? But then what…? I just can’t seem to work out the best way of doing this.

Any help would be appreciated! Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T09:37:31+00:00Added an answer on May 14, 2026 at 9:37 am

    I finally figured out this and thought I’d provide the answer in case it proves useful to others. Below is a small helper class that uses XsltCompiledTransform and also can cache the results. It was written specifically for caching Umbraco macros, but can be used in any situation, I believe.

    public static class XsltHelper
    {
        /// <summary>
        /// Returns a compiled XSLT transform object for an XSLT file and caches it
        /// </summary>
        /// <param name="XsltFile">The relative path to the XSLT file</param>
        /// <returns>An XslCompiledTransform object for the XSLT file</returns>
        public static XslCompiledTransform GetXslt(string XsltFile)
        {
            string cacheKey = "macroXslt_" + XsltFile;
    
            if (System.Web.HttpRuntime.Cache[cacheKey] != null)
            {
                return (XslCompiledTransform)System.Web.HttpRuntime.Cache[cacheKey];
            }
            else
            {
                return GetXSLT(XsltFile, cacheKey);
            }
        }
    
        private static XslCompiledTransform GetXSLT(string XsltFile, string cacheKey)
        {
            XslCompiledTransform macroXSLT = new XslCompiledTransform();
    
            using (XmlTextReader xslReader = new XmlTextReader(System.Web.HttpContext.Current.Server.MapPath(XsltFile)))
            {
                try
                {
                    xslReader.EntityHandling = EntityHandling.ExpandCharEntities;
                    XmlUrlResolver xslResolver = new XmlUrlResolver();
                    xslResolver.Credentials = CredentialCache.DefaultCredentials;
    
                    XsltSettings settings = new XsltSettings();
                    settings.EnableDocumentFunction = true;
                    settings.EnableScript = true;
                    macroXSLT.Load(xslReader, settings, xslResolver);
    
                    System.Web.HttpRuntime.Cache.Insert(cacheKey, macroXSLT,
                        new System.Web.Caching.CacheDependency(System.Web.HttpContext.Current.Server.MapPath(XsltFile)));
                }
                catch
                {
                    throw;
                }
            }
    
            return macroXSLT;
        }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.