.NET 获取页面全部代码

    private static string TextFromFile()

    {

        string sLine = "";

        using (StreamReader objReader = new StreamReader(HttpContext.Current.Server.MapPath("Default.aspx"), System.Text.Encoding.Default))

        {

            StringBuilder sb = new StringBuilder();

            while ((sLine = objReader.ReadLine()) != null)

            {

                sb.AppendLine(sLine);

            }

            objReader.Close();

            sLine = sb.ToString();

        }

        return sLine;

    }

你可能感兴趣的:(.net)