简体   繁体   English

如何在Visual Studio 2015社区中通过代码添加新项目?

[英]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内容管理,则可以使用以下提供程序:

Umbarco or Sitecore UmbarcoSitecore

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.

相关问题 如何在Visual Studio 2015社区中添加构建属性/宏 - How to Add Build Properties / Macros in Visual Studio 2015 Community Visual Studio社区2013年缺少C#添加新项 - Visual Studio Community 2013 Missing C# Add New Item Visual Studio 2015 Community Edition无法下载新许可证 - Visual Studio 2015 Community Edition failed to download new license 如何从 Visual Studio 2015 社区版打开新的“ASP.NET Web 应用程序”? - How to open new "ASP.NET Web Application" from visual studio 2015 community edition? Visual Studio 2015社区中“添加视图”对话框的区别 - Difference in Add View dialog box in Visual Studio 2015 Community 无法将文件添加到Visual Studio 2015(社区)更新3 / TFS - Cannot add files to Visual studio 2015 (Community) Update 3 / TFS Visual Studio 2015 社区 C# 计算器代码错误 - Visual Studio 2015 Community C# Calculator Code Errors Visual Studio Community 2019 16.5.3 与 Blazor 应用程序 -> 添加 -> 新项目 -> Razor 组件 -> 路由或组件未呈现 - Visual Studio Community 2019 16.5.3 with Blazor App -> Add -> New Item -> Razor Component -> Route or component is not rendered 如何在Visual Studio社区2015中将Copy Local Property设置为true - How to Set the Copy Local Property to true in visual studio community 2015 如何为Visual Studio 2015社区安装EF电动工具 - how to install EF power tools for visual studio 2015 community
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM