How to concatenate web pages in ASP.NET

I have a bunch of ASP.NET web pages (which have a standard layout) that are product documentation. I want to create some kind of combinational page that will pull out all the contents of another page and combine them into one long page.

IFrames will not work because I do not know the size of each page. I could have a page combination containing a ton of #includes, and this will work, but I don't want the latest repository update (we have a database of page names that can change over time).

Ultimately, I am for something that can get a list of pages, and for each of them the equivalent of #include for this page on the current page.

Hope this makes sense. Any thoughts?

+3
source share
5 answers

Are your "documentation pages" static html or .aspx ...

if it's just static content, you can do the following

//assume that the array of page names has come from the DB.
protected void Page_Load(object sender, EventArgs e)
{
    string[] pages = new string [] { "~/Default.html", 
             "~/Default2.html", "~/Default3.html", "~/Default4.html" };

    foreach (string p in pages)
    {
        Response.WriteFile(p);
    }
}
+1
source

What do your pages look like?

I assume these are just HTML files and have a consistent template on all pages, no? For example, it has proper HTML markup along with HEAD and BODY, etc.

In this case, you can simply read it as if you were reading normal text files and doing some parsing on them to extract a part inside the BODY tags, and then you can just concatenate them and print them in ASP- # include style.

To get the actual file path name on the ASP.NET website, you can use Server.MapPath

var actualDiskFilename = Server.MapPath("~/somewhere/somepage.html");

System.IO ASP.NET, , :

var virtualDir = "~/somefolder/";
var actualDir = Server.MapPath(virtualDir);

var files = Directory.GetFiles(actualDir);

, ?

0

aspx-, Server.Execute html. html head- body html .

0

, IFRAMES , ? IFRAMES .

IFRAME , javascript . javascript, ​​ jquery

0

It sounds as if you should redefine the format from the very beginning, if possible. For example, if you saved content in a database or XML files, your individual pages could serve their section, and your conglomerate page could serve any combination of the total you want.

It would not be so difficult to convert if you speak only a few pages (less than a dozen). Then updating the documentation up to date is a matter of editing the content, not the display files (admittedly, XML is simpler than a database in this regard).

0
source

Source: https://habr.com/ru/post/1698708/


All Articles