Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Normally, when your browser requests a file ending in .aspx from a remote server, the file is first parsed by the server and then rendered into HTML and JavaScript. The HTML and JavaScript is then displayed by the browser in place of the ASP Markup that the page is written in.

Is there any way, using a variant of the following code, to get the ASP file as is, with full (unparsed) markup?

C#
void GetFile(string URL, string destPath)
        {
            if (string.IsNullOrEmpty(URL))
                throw new ArgumentNullException("URL");

            if (string.IsNullOrEmpty(destPath))
                throw new ArgumentNullException("destPath");

            WebRequest request = WebRequest.Create(URL);
            WebProxy proxy = WebProxy.GetDefaultProxy();
            proxy.UseDefaultCredentials = true;
            request.Proxy = proxy;

            using (Stream stream = request.GetResponse().GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    File.WriteAllText(destPath, reader.ReadToEnd());
                }
            }

            MessageBox.Show("Done downloading the file " + Path.GetFileName(destPath),
                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Posted

1 solution

No, not unless somebody has gone out of their way to make this possible when they set up the web site.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Uday P.Singh 30-Aug-11 16:29pm    
Agree my 5!
Espen Harlinn 30-Aug-11 16:30pm    
Thank you, Uday!
Sergey Alexandrovich Kryukov 30-Aug-11 17:27pm    
You are right, my 5.
I would say: "From the standpoint of client side, there is no such thing as .aspx file".
--SA
Espen Harlinn 30-Aug-11 17:43pm    
Thanks Sergey :)
RaisKazi 31-Aug-11 0:47am    
Agree 5!. All you need is permissions to get into 'Home' of someone else :). By providing Cridentials this type of request can be made.
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900