[英]How to add a new item through code in visual studio 2015 community?
I want to add a new webpage through code. 我想通过代码添加新的网页。 Normally we would just right click and select add new item, but i want to know if there's a way that i can just code to add new items.
通常,我们只需要右键单击并选择添加新项目,但是我想知道是否有一种方法可以通过代码添加新项目。 The reason why i wanted to know about this is because i'm trying to create a content management system, and it requires to create a new webpage.
我想知道这一点的原因是因为我正在尝试创建一个内容管理系统,并且它需要创建一个新的网页。 Since the user does not know how to create it in visual studio 2015, I will need to create a system where the user can create their own webpage via the actual website.
由于用户不知道如何在Visual Studio 2015中创建它,因此我将需要创建一个系统,用户可以在该系统中通过实际网站创建自己的网页。 Like for example: I wanted to add new webpage called "Test.aspx" in my Pages folder.
例如:我想在我的Pages文件夹中添加一个名为“ Test.aspx”的新网页。 The question is how can i do it in code?
问题是我该如何在代码中做到这一点? Hope this makes sense.
希望这是有道理的。
Normally, we would add items like the picture below. 通常,我们将添加如下图所示的项目。
What you are trying to do using Visual Studio , is not designed for. 您使用Visual Studio尝试执行的操作不是针对的。
Visual studio is used for writing code and not as a content management system. Visual Studio用于编写代码,而不用作内容管理系统。
How ever , if you would like to use ASP.NET content management , then there are providers such as : 但是,如果您想使用ASP.NET内容管理,则可以使用以下提供程序:
I sense security issue if visual studio allow creation of source file programmatically, that's what I thought at first. 如果Visual Studio允许以编程方式创建源文件,我会感觉到安全问题,这就是我最初的想法。
But I came across this link afteerwards: http://www.codedigest.com/Articles/ASPNET/170_Creating_ASPX_Page_Dynamically_in_ASPNet.aspx 但是我后来遇到了这个链接: http : //www.codedigest.com/Articles/ASPNET/170_Creating_ASPX_Page_Dynamically_in_ASPNet.aspx
And it seems like possible. 似乎有可能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.