I have been using PHP for a long time, but I want to move to C#. However, I don’t care much for web controls and the template system. Don’t get me wrong, it is good for many projects, but not all. Sometimes I want to use my own template system
I just want to run my code on every page request and print some HTML, CSS or whatever. Just something like Response.Write() or PHPs “echo” without all the templates and controls. What is the best way to achieve this?
Edit:
This is how I would like it to work:
private void Page_Request(object sender, EventArgs e)
{
// Do my stuff here
Response.Write(myhtml);
}
If you want it to be as bare bones as possible, you could use generic handlers (.ashx).
You can register routes in your web.config file, to direct the request to the appropriate handler.
I wouldn’t recommend this approach though. Seems like a lot of extra work (you will need to write everything to the response), and will be prone to errors when you want to make changes.