Can I export generated html pages from an ASP.NET website through Visual Studio?

My friend uses Visual Studio to develop websites in ASP.NET. It uses only the master page, except that it is 100% normal HTML and CSS.

Is there a way to export a website to HTML pages based on their master pages?

If not, it’s either loading each page manually, or saving HTML, or I'm writing a small application that does this.

Alternatively, does anyone know a tool to achieve something like this?

+5
source share
7 answers

Visual Studio . , , html , .

+1

, .

- -. - TeleportPro, . , .

+1

Macromedia Dreamweaver , . .

+1

MasterPages MasterPage ( , ). , MasterPage aspnet_compile - . . "Runtime Behavior" MSDN.

, , (, , , MasterPage ):

<!--#include virtual="/includes/header.html" -->
<!--#include virtual="/includes/nav.html" -->

<p> content </p>

<!--#include virtual="includes/footer.html" -->

-/ ( ), Ajax DIV. , Javascript , .

+1

, . URL- :

  Public Shared Function GetHTTPContent(ByVal url As String) As String
    Dim req As WebRequest = System.Net.HttpWebRequest.Create(url)
    Dim encode As System.Text.Encoding = System.Text.Encoding.GetEncoding("utf-8")
    Dim sr As New StreamReader(req.GetResponse().GetResponseStream(), encode)
    Dim HTTPContent As String = sr.ReadToEnd

    sr.Close()
    sr.Dispose()

    Return HTTPContent

End Function
+1

, :

HTTrack Website Copier

spidering, , .

0

, .aspx .html html.

protected void ButtonGenerate_Click(object sender, EventArgs e)
{
    RecursivelyGenerateHtmlFiles(Server.MapPath("~/"), new DirectoryInfo(Server.MapPath("~/")));
}

private void RecursivelyGenerateHtmlFiles(string root, DirectoryInfo folder)
{
    foreach (var aspxPage in folder.GetFiles("*.aspx"))
    {
        var destination = aspxPage.FullName.Substring(0, aspxPage.FullName.Length - 4) + "html";

        if (File.Exists(destination))
            File.Delete(destination);

        var url = "http://" + Request.Url.Authority + "/" + aspxPage.FullName.Replace(root, "");
        var request = HttpWebRequest.Create(url);

        File.WriteAllText(destination, new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd());
    }

    foreach (var subDirectory in folder.GetDirectories())
    {
        RecursivelyGenerateHtmlFiles(root, subDirectory);
    }
}

.

, .bat .html . .

set folder="Generated"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
cd /d ..
xcopy /r /d /i /s /y /exclude:exclude.txt PAHtml Generated

exclude.txt

.dll
.cs\
.aspx
.pdb
.csproj
.user
.vspscc
.config
0

All Articles