[英]How to access web page hierarchy inside a application
Trying to figure out how to programmatically access the web pages in the application. 试图弄清楚如何以编程方式访问应用程序中的网页。 Just something simple like a list of them would be awesome.
像清单这样简单的东西就很棒。 I know I can create a list but I was wondering if there was something that could 'look' at the pages and add a new one to the list if you make a new page for the application.
我知道我可以创建一个列表,但是我想知道是否有可以“查看”页面的东西,如果为应用程序创建新页面,可以在列表中添加新的东西。
Example with 7 pages: 7页示例:
Error
Default
Login
Content
Users
ContactUs
Admin
I am half awake so I may be a little unclear. 我半醒着,所以可能不清楚。 Maybe puting it all in a single question will be easier.
也许将所有问题放在一个问题中会更容易。
How do you autogenerate a list of all webpages in your current application? 您如何在当前应用程序中自动生成所有网页的列表?
In a traditional ASP.Net application, you can simply find all of the .aspx files, like this: 在传统的ASP.Net应用程序中,您可以简单地找到所有.aspx文件,如下所示:
Directory.GetFiles(Server.MapPath("~/"), "*.aspx", SearchOption.AllDirectories)
Note that this will return full filepaths; 注意,这将返回完整的文件路径。 you can call
Path.GetFileNameWithoutExtension
to get the names. 您可以调用
Path.GetFileNameWithoutExtension
来获取名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.