Microsoft
Software
Hardware
Network
Question : Storing a web page's data stream in a string
I would like to store the streamed html output of an .aspx file (the html that the end user sees) into a string in C#. Is there an efficient & simple way to do this?
MetaFile.aspx.cs
------------------------
public void Page_Load()
{
string [3] s;
string s[1] = UserOutputOf("SubFile.aspx
");
string s[2] = UserOutputOf("
www.somewher
eOnWeb.com
/home.html
");
string s[3] = UserOutputOf("
www.somewher
eOnWeb.com
/try.aspx
"
);
Response.Write(s[Random(3)
]); // psuedo code
}
So when mysite.com/Metafile.aspx is typed into a web browser it will return, at random, one of the three:
* the same output as mysite.com/SubFile.aspx
* the same output as
www.somewhereOnWeb.com/hom
e.html
-- except broken images & links & such
* "" /try.aspx ""
The purpose here is not to copy the look of the web page, but to take in the same HTML stream that a web surfer's browser would see in these instances (given that this web surfer is the code above) and store it in a string.
What would the function UserOutputOf(string web_addr) look like?
Answer : Storing a web page's data stream in a string
use Server.Execute ............
StringWriter objsw = null;
objsw = new StringWriter();
Server.Execute("defult.asp
x" , objsw);
string sHtML = objsw.GetStringBuilder().T
oString();
Random Solutions
Open Sharepoint server's pdf file in asp.net...
windows 7 - how to view classic windows explorer
how do I access and manipulate the connectionString in app config?
Checking Value of Import Text File
Microsodft system center virtual machine manager 2008
Can Sharepoint access
Access Database Will Not Open - Error "Not a Valid Bookmark"
Script to automatically run the saved imports in an access database
C# VS2008 Win App - HOw can I create nice form skins - can I download them?
All mailboxes in mailbox store in exchange have disapeared