physical html files on fly vs2005

can we genrate HTL files on the fly? like client enters data in a text box his physical file is created on the server like free web page. using  from choice of master Pages.

VS2005, ASP.NET C#
Who is Participating?
DBAduck - Ben MillerPrincipal ConsultantCommented:
If I understand you right, you really want to know if you can create a file and save it to your website.

Yes you can do this if you have CREATE rights on the folder (I mean the anonymous rights user).
You can use File.Exists(path) to find out if it exists, and you can use FileStream fs = File.Create(path).

Take a look at this

It explains how to use the FileStream object.  But inside the file you create, you can put all the header information like <%@ Page MasterPageFile="~/sometihing.master" ... %>

Hum... If I understand you correctly, you want to generate dynamicallly the output rendered to the user, right?  Well, this is precisely what .NET is intended for.  There are many ways to go about this.  One is to dynamically populate the page with controls as it is being prepared for rendering.  You could override the OnInit() or OnPreRender() methods and add controls at will.

My preferred method is to use dynamic templates (I am still stuck using .NET 1.1, so I have no access to master pages).  But I suppose that with master pages it is even easier.

dontnetsanjayAuthor Commented:
hello dropzone,
not this what i want to know
dynamically generating content for a web page thru databases text file or xml
using master pages or user controls are different concepts

create a physical html file suppose i have ntered file namein a text box say drop.html
then only we will check whether file exists or not and if ot then we create a file drop.html and adding content to that file is secondary issue which is not my query

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

I understand.  This is possible.

You can dynamically change the URL by using the HttpContext.RewritePath() method.  You can do this from the Application_BeginRequest() event.  At that point, you can check if the file exists, and if not, create it.  You can also set a custom ASPX page for the 404 error (file not found), and in this page, generate dynamic content depending on the original request.

It depends on what you want to do ultimately.  If you provide more details, we may be able to offer specific help.

I would suggest to use a component like Rewrite.NET. This allows the user to navigate the page "drop.html", but you don't need to actually create it. You can store the content in a database and use 1 page with a literal control on it which will hold all content.

You can find more information on:
dontnetsanjayAuthor Commented:
hey dbaduck,

thanks for the answer thats what i wanted to know and its completely clear now thanks

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.