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

  • SEARCH
  • Home
  • 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 164913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:49:42+00:00 2026-05-11T11:49:42+00:00

Is there a way to change ASPX file soure before it is precompiled into

  • 0

Is there a way to change ASPX file soure before it is precompiled into temporary files.

i.e. to remove empty spaces and new lines.

  • 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. 2026-05-11T11:49:43+00:00Added an answer on May 11, 2026 at 11:49 am

    Yes, there is, but it is not easy and may not be worth your trouble.

    One way of doing it is to create your own BuildProvider and replace the default System.Web.Compilation.PageBuildProvider with it in the config file:

    <compilation debug='true'>     <buildProviders>         <add extension='.aspx' type='MyProject.MyPageBuildProvider' />     </buildProviders> </compilation> 

    You would also create your own PageParser, most likely inherited from the TemplateParser. The BuildProvider is responsible for supplying the PageParser. In most primitive situation you could overwrite the ParseFile method, read the ASPX file, process it, create a copy and pass it to the base method.

    Unfortunately, all ASPX parsing code is sealed and internal to MS libraries, so you can’t inherit. Rewriting it would mean building entire compilation engine.

    The alternative method is to create your own page builder and put it in the attribute. The drawback is that you get an easy access to literals (all your spaces etc) of the first level (the page) only. To get to inner controls and their literals, you have to either hack the parser using reflection or (proper) manipulate the code dom. This way you would get properly built .cs files and temporary assemblies.

    Here is a simplified sample:

    namespace MyProject {     [FileLevelControlBuilder(typeof(MyPageBuilder))]     public partial class _Default : System.Web.UI.Page     {         //this is Default.aspx     }      //The builder of the page     public class MyPageBuilder : FileLevelPageControlBuilder     {         //This is where you'd strip white space, but only of top level,         //such as between the head and form, or form and the end of file         public override void AppendLiteralString(string text)         {             //let's replace some white spaces with garbage             base.AppendLiteralString(text.Replace(' ', '#').Replace('\t', '@').Replace('\r', '$').Replace('\n', '%'));         }          //Here you can manipulate the entire generated code using CodeDom         public override void ProcessGeneratedCode(System.CodeDom.CodeCompileUnit codeCompileUnit, System.CodeDom.CodeTypeDeclaration baseType, System.CodeDom.CodeTypeDeclaration derivedType, System.CodeDom.CodeMemberMethod buildMethod, System.CodeDom.CodeMemberMethod dataBindingMethod)         {             base.ProcessGeneratedCode(codeCompileUnit, baseType, derivedType, buildMethod, dataBindingMethod);         }          //Alternatively, you can 'hack' the PageParser here using reflection         //However, the _text field at this point is irrelevant, so it can't be used         public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, System.Collections.IDictionary attribs)         {             FieldInfo fi = parser.GetType().BaseType.BaseType.BaseType.GetField('_text', System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);             string s = (string) fi.GetValue(parser);             fi.SetValue(parser, s.Replace('\t', '*'));              base.Init(parser, parentBuilder, type, tagName, ID, attribs);         }     } } 

    In my opinion, it is not worth the effort.

    edited typo

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

Sidebar

Related Questions

Is there a way to change location of IsolatedStorage files? I am using .NET
Is there any way to change the BackColor of the border of a panel
Is there any way to change the icon of an application after it is
Is there a way to change the root folder for the views to the
Is there a way to change the alignment of the icon or text of
Is there a way to change the value contained in an NSNumber after it
Is there a way to change the order of the controls inside a StackPanel
Is there a way to change the application language during runtime? So, after the
Is there a way to change the default ajax progressbar that is there in
is there a way to change the background color of a QTextBlock in a

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.