• We just launched and are currently in beta. Join us as we build and grow the community.

Show Source Code of Aspx webpage and code file in Browser window

MI6

SERP Dominator
M Rep
0
0
0
Rep
0
M Vouches
0
0
0
Vouches
0
Posts
115
Likes
23
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
For show your source code of aspx page, u have to used System.IO namespace

1) Read Default.aspx File
Aspx file contain both html and aspx server control tag so used File Stream and read a aspx file.
Server.HtmlEncode (String val) takes a string argument and return all aspx code as a string.
string FilePath = Server.MapPath("Default.aspx");
//get the physical path
StreamReader sReader = new StreamReader(FilePath);
//Create object of StreamReader
string FileContent = string.Empty;
FileContent = "<pre>" + Server.HtmlEncode(sReader.ReadToEnd()) + "</pre>";
lblaspxsource.Text = FileContent;
sReader.Close();

2)Read Default.aspx.cs File
Use tage to show your aspx(C#,VB) code into browser window
string FilePath = Server.MapPath("Default.aspx.cs");
StreamReader sReader = new StreamReader(FilePath);
string FileContent = string.Empty;
FileContent = "<pre><code>" + Server.HtmlEncode(sReader.ReadToEnd()) + "</code></pre>";
lblsourcecodeCSFile.Text = FileContent;
sReader.Close();

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

 

440,010

316,559

316,568

Top