1

There are two types of pages in sharepoint. Application and site pages. In site pages if we want to customize them, are we not able to use the server side code? If so why? I saw an article related to this in MSDN.

Generally what is meant by customized here. Adding a webpart through the code is customization? Please explain me any one.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Searcher
  • 1,845
  • 9
  • 32
  • 45

2 Answers2

2

Without a web.config modification (not recommended), Site Pages do not support server side code (either inline or in a code behind file). This is primarily for security and performance reasons. Unlike Application Pages, Site Pages can be added or modified in SharePoint Designer and, in a limited fashion, through the browser.

Normally, there are many more users with these privileges than those users that have access to the web server. I'll leave it to your imagination to consider some of the insecure or inefficient server side code some of these users could create.

In addition to custom web parts, see Where's the code-behind for sharepoint aspx pages? for server side code options within Site Pages.

Community
  • 1
  • 1
Rich Bennema
  • 10,295
  • 4
  • 37
  • 58
0

When you're doing application page, you're storing the aspx with the 12 / 14 hive (SharePoint installation directory) and you're free to use any code behind class / component that you want to use. The original aspx file will stay in the physical folder of the Web Frond End

On the other side, when you're creating site pages, you're adding a new entry within the content database and not on the file system. Even if you have a site page template, you need to add safe entries to your web.config to trust the assemblies.

For the site pages, it is suggested to work with WebParts. They will allow you do do any business / core logic with the actual page, list, web, site.

When they talk about customization, they talk about modification done to the site pages that will alter the original definition. A site page provisioned through a web definition will stay "uncustomized" (ghosted) in the file system until it is being edited.