Create and deploy site pages or content pages using visual studio in SharePoint 2013/2016

Create and Deploy SharePoint 2013 site pages or content pages using Visual Studio 2013
SharePoint deveopment training course

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:

create custom site page sharepoint 2013

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.

create custom site page sharepoint 2013 programmatically

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:

create custom site page sharepoint 2016 programmatically

Next, rename the Sample.txt to aspx page. It should look like below:

create custom site page sharepoint 2013 visual studio

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:

how to create custom site page in sharepoint 2013

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:

Create and Deploy SharePoint 2013 site pages

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:

Create and Deploy SharePoint 2016 site pages

Then you can navigate to the page URL and you can see the page like below:

http://win-pfcp2dgt8di/sites/EnjoySharePoint/MySampleSitePage.aspx
Create and Deploy SharePoint 2013 site pages using visual studio

You may like following SharePoint tutorials:

This SharePoint tutorial, we learned how to create and deploy site pages or content pages using visual studio in SharePoint 2013/2016.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →