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

Ask A Question

Stats

  • Questions 181k
  • Answers 181k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I came across this fantastic list of software for computer… May 12, 2026 at 4:09 pm
  • Editorial Team
    Editorial Team added an answer http://www.moyosoft.com/joc/ May 12, 2026 at 4:09 pm
  • Editorial Team
    Editorial Team added an answer >>> import re >>> re.sub(' +', ' ', 'The quick… May 12, 2026 at 4:09 pm

Related Questions

We have a legacy ASP.net powered site running on a IIS server, the site
I've have been using Visual Studio 2005, alongside Visual Web Developer 2008 to create
I have a page that has a left menu in it. This left menu
If I put a control in a .aspx file like this; <asp:TextBox ID=protectedTextBox runat=server>Some

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.