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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
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:
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:
In my opinion, it is not worth the effort.
edited typo