0

I don't know if this is a stupid question but..

Is it possible in either ASP.NET (either C# or VB#) to Response.Write() the contents of another HTML file? If so, how?

1
  • Inline in the current file or instead of it? Commented Dec 22, 2010 at 13:02

3 Answers 3

4

Read the HTML file line by line and write it using Response.Write()

 StreamReader sr = new StreamReader(@"C:\abc.html"); while(sr.Peek() >= 0) { line=sr.ReadLine(); Response.Write(line); } 
Sign up to request clarification or add additional context in comments.

Comments

2

You can get all the lines into a string array and send them out directly.

string[] lines = File.ReadAllLines("path/to/my/file.html"); foreach(string line in lines) { Response.Write(line); } 

Just don't forget to set your headers up correctly because this will just inject HTML. It won't set up any special headers that might be expected (if any).

Comments

1

I know this is an old question, but I have another solution for future researching. How about just use TrasmitFile? i.e.:

Response.WriteFile(@"folder/filename.html"); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.