How to create html file on the fly in .NET

245 Views Asked by At

I am interested to know that how can I create html file on the fly in .NET. I have a scenario in which the user request a page something like

http://mydomain.com/country/123.html

I want to create that html file on the fly, Bind the content of the page dynamically and show it to the end user? Can someone please suggest what should I need to do to make it possible?

1

There are 1 best solutions below

0
On

This is a rather odd requirement and without a lot of context it's quite hard to answer.

There are two approaches you could take.

The first would be to analyse the request as it comes in in the Global.cs's Application_BeginRequest method. If it didn't request you could then create the file in question.

Your other option would be to create a HttpHandler and direct traffic to it. This wouldn't actually create the file on the server but depending on your requirements it could meet your requirements.