This SharePoint tutorial explains, how to create and deploy SharePoint 2013/2016 site pages or content pages using visual studio 2013/2015/2017.
Content pages are pages where the content resides. To create a content page using visual studio 2013, follow the below steps.
Create and deploy site pages or content pages using a visual studio in SharePoint
Open Visual Studio 2013/2015/2017 then click on File -> New -> Project. This will open the New Project dialog box, From the left side from the installed templates, go to Templates -> Visual C# -> Office/SharePoint -> SharePoint Solutions. Then choose SharePoint 2013 – Empty Project. Make sure to choose the .NET Framework 4.5 version. Give a name and location as shown in the fig below:
Then give a local site for debugging. And then choose the option as a farm solution. You can choose here Sandboxed solutions also. But in this example, I have chosen a farm solution.
Then Right-click on the Project then Add -> Add new project. In the Add New Item dialog box, from the installed templates select Visual C# Item, Office/SharePoint and then choose Module. Give a name for the Module as shown in the fig below:
Next, rename the Sample.txt to aspx page. It should look like below:
Then put the below content to the .aspx page.
<%@Page MasterPageFile="~masterurl/default.master"%>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<h1>This is our custom page which we have created using Visual Studio 2013</h1>
</asp:Content>
It should look like below:
Also, change the Elements.xml file like below:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages">
<File Path="Pages\MySampleSitePage.aspx" Url="MySampleSitePage.aspx" />
</Module>
</Elements>
Now rename the feature to a meaningful name as shown in the fig below:
Now it is time to deploy the solution. Right-click on the Solution click on Deploy Solution which will deploy the solution to the local SharePoint site which you have provided at the beginning.
But if you want to deploy to any other server other than development servers like stage or production server then you can follow this URL to know how we can deploy the solution using PowerShell.
Once it is successfully deployed, we can verify the feature. Open your SharePoint site then click on the gear icon then Site Settings. Under Site, Actions click on Manage site features. This will open the Site Features page, you can see the “MyCustomPage Feature1″ will be inactivated state as shown in the fig below:
Then you can navigate to the page URL and you can see the page like below:
http://win-pfcp2dgt8di/sites/EnjoySharePoint/MySampleSitePage.aspx
You may like following SharePoint tutorials:
- SharePoint Hosted Add-in: Send Email to SharePoint group using visual studio workflow
- Create a Web API for SharePoint Online and Deploy to Microsoft Azure using Visual Studio (Step by Step tutorial)
- Develop SharePoint workflows using visual studio as SharePoint hosted App
- Create a Custom Action Group using Visual Studio 2015 for SharePoint 2016
- SharePoint Online Develop SharePoint Hosted Add-in using Visual Studio 2015 Demo
- SharePoint 2016 Develop and deploy custom feature using Visual Studio 2015
- SharePoint 2016 How to create list instance and list definition using Visual Studio 2015
- Create a web part page using visual studio 2013 in SharePoint 2013
- How to create site definition using Visual Studio 2013 in SharePoint 2013
- Create List Definition and List Instance in SharePoint 2013/2016 using Visual Studio 2013/2015/2016
- SharePoint 2013 Create a custom master page using Visual Studio 2013
- Create an application page in SharePoint 2013 using visual studio 2013
This SharePoint tutorial, we learned how to create and deploy site pages or content pages using visual studio in SharePoint 2013/2016.
Bhawana Rathore is a Microsoft MVP (3 times in Office Apps & Services) and a passionate SharePoint Consultant, having around 10 years of IT experience in the industry, as well as in .Net technologies. She likes to share her technical expertise in EnjoySharePoint.com and SPGuides.com