如何从Web服务器下载.aspx文件本身? [英] How do I download a .aspx file itself from the Web server?

查看:597
本文介绍了如何从Web服务器下载.aspx文件本身?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当浏览器从远程服务器请求以.aspx结尾的文件时,该文件首先由服务器解析,然后呈现为HTML和JavaScript.然后,浏览器会显示HTML和JavaScript来代替编写页面的ASP标记.

是否可以使用以下代码的变体以完整(未解析的)标记按原样获取ASP文件?

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?

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);
        }

推荐答案

否,除非有人在设置网站时全力以赴,使之成为可能.
最好的问候
Espen Harlinn
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


这篇关于如何从Web服务器下载.aspx文件本身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆