However, I would like to improve my architecture and create a HttpModule that does the work for me.
I have provided code for .NETv1.0 that ensures valid XHTML is output for .NETv1.0 sites (i.e. viewstate must be put within DIV tags and form must use 'id' attribute instead of name). This will provide a great example of how to achieve what I am after.
This code will be great for all .NETv2.+ developers working on web projects.
Have you, or are you aware of the .NET 2.0 Control Adapters? This allows you to change the output of all the base controls like forms, form controls etc...
Andrew
smacca
ASKER
Have not heard of control adapters but you have my curiosity at a peak.
Will look into this tonight - thanks for the great tip.
Would the adapters be preferable in this case?
I still think HttpModule is best as it grabs the HTML stream and modifies it.
REA_ANDREW
I have been looking into this, and it does not seem that a HttpModule or Handler seem sto be a vlaid approach, simply because you either cannot or are limited to the page output before it is renedered. This is why overriding the Page Render Method seems to be the best way.
I create a derived Page Class called SEOPage and implemented that render code! Works a treat.
I will try and look into it more as I can see where you are going. My other attempt was to use
Server.Execute(FilePath, TextWriter) this way I can programatically render a page, change it and spew out the html to the context. I cannot do this though, as the Server.Execute method fails each time when I hook it up to a aspx request.
Fantastic you are using the Render code in your basepage. It is really great.
Has potential to give you improved results for Search Engine ranking - as outlined in the referenced material.
Would love to see a HttpModule at work.
I have provided a working sample of a HttpModule I use with my .NETv1.0 sites to output valid XML.
It would be a great starting point for yourself or any other developers.
Am totally confident you would use in all projects, once it was written - one of those, write once use forever bits of code.
Andrew, your a legend - is that a working sample?? Does it work a treat??
Thanks for your time - it is much appreciated.
REA_ANDREW
Yes, I tried here on my local computer, and it works a treat. I am glad you asked the question now, as I will be implmenting this on my server to test out!!
Is this working fine for your Andrew - I havent used since we discussed as it may have been causing bugs - not completely sure though as project was in start period.
Andrew