简体   繁体   English

基于xml内容文件和母版页动态生成aspx页

[英]Dynamically generate aspx pages based on xml content files and a master page

I want to develop a web application with a master page containing an <asp:Xml /> control for rendering xhtml content stored in xml files. 我想开发一个Web应用程序,其母版页包含用于呈现存储在xml文件中的xhtml内容的<asp:Xml />控件。

I can do this easily enough by creating a WebContent aspx page per xml file, but what I want to know is how to go about developing a single request handler which will detect a request for a page eg www.mysite.com/HomePage.aspx then generate a page based on the master page and assume that a corresponding xml content file exists (eg HomePage.xml). 通过为每个xml文件创建一个WebContent aspx页面,我可以很容易地做到这一点,但是我想知道的是如何开发一个将检测页面请求的单个请求处理程序,例如www.mysite.com/HomePage.aspx然后基于母版页生成一个页面,并假定存在相应的xml内容文件(例如HomePage.xml)。

here is the flow for this process. 这是此过程的流程。
- use a http module. -使用http模块。 module gets 模块获取
- request get requested page name and find xls file. -请求获取请求的页面名称并查找xls文件。
- populate xsl file data as xml. -将xsl文件数据填充为xml。
- merge xml and xls. -合并xml和xls。
- send response to client. -向客户发送回复。

I've decided to tackle this in a different way... 我决定以其他方式解决这个问题...

I'm using UrlRewritingNet to handle requests for pages and have a single page (ShowPage.aspx) which loads the appropriate xml content file depending on a url parameter. 我正在使用UrlRewritingNet来处理页面请求,并具有一个页面(ShowPage.aspx),该页面根据url参数加载适当的xml内容文件。 So if the page www.mysite.com/about-us.aspx is requested, this is handled by www.mysite.com/ShowPage.aspx?PageName=about-us and inside ShowPage.aspx I have code as follows: 因此,如果请求页面www.mysite.com/about-us.aspx ,则由www.mysite.com/ShowPage.aspx?PageName=about-us处理,并且在ShowPage.aspx内部,我具有以下代码:

protected void Page_Load(object sender, EventArgs e)
{
    string xmlFile = "~/" + Request["PageName"] + ".xml";
    xmlContent.DocumentSource = xmlFile;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM