开发者

how to save aspx file as html file and folder to local machine or server

in my web application my client wants to save the current aspx page as html file and also save the related file(jquery, images ...) in a folder. basically that what is being done in the background when you right click and press "save to" in the browser and I want to do that by a click of a button(webcontrol).

i found a piece of code that will save the html file itself but i don't know how to save also the related folder.

private void SavePageASHtml(string location)
    {
        StringWriter stringWriter = new StringWriter();

        HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

        Page.RenderControl(htmlWriter);

        htmlWriter.Flush();

        FileStream fileStream = new FileStream(location, FileMode.Create);

        string siteString = stringWriter.ToString();

        byte[] byteArray = Encoding.UTF8.GetBytes(siteString);

        fileStream.Write(byteArray, 0, byteArray开发者_运维百科.Length);

        fileStream.Close();

        Response.End();

        Response.Redirect("~/PriceList.aspx");
    }


Simply right click on page and save html, it will save everything direcctly linked to the page,.i.e, images,js and css


This is a pretty old article, but it shows how to save as an MHT file, which is quite close to what I believe you want:

http://www.eggheadcafe.com/articles/20040527.asp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜