Friday, October 12, 2007

Add aspx page to SharePoint 2007

            This post will show how to create aspx (web page) page to SharePoint 2007. You can find  a really good article to add custom page in SharePoint 2007 site. I have shown one approach describe in above article.

            Create a new Web Application Project from Visual Studio 2005. You need to download web application project extension for this. Open Visual Studio 2005 and select Web Application Project as shown below,

NewWebProject

Fig - (1) Create new Web Application

            Name the project "FirstWebProject". Delete Default.aspx page and add new Web Page and name it to "FirstCustomePage.aspx".  You can design this page as you want. Once you are done with designing run the application once to make sure that there is no error.

            Now go to the file path where you have created the Web Application. Here in my case as you can see in figure - (1) file path is "c:\chirag\VortalProject". You have to copy the DLL file from web application's BIN folder to share point site's BIN folder. To Find BIN folder for your share point site, go to IIS and select your share point site. Right click on the site name and click on Open.

LocateBin

Fig - (2) Locate BIN Directory for SharePoint Site.

          This will open physical location where you site resides. Copy web application's DLL file (In my case "FirstWebProject.dll") in BIN directory of SharePoint site.

          Now create a new folder at same level where your SharePoint site's BIN directory resides. Name is "CustomePage". Add the "FirstCustomePage.aspx" page to "CustomPage" folder.

         Open Web.Config file of Share Point site and copy safe control tag shown below to Web.Config file.

<SafeControl Assembly="FirstWebProject" Namespace="FirstWebProject" TypeName="*" />

Fig - (3) Safe Control Tag.

         If you have chosen different namespace and assembly names than you have to use your name instead of this. You have completed 90% of the task.

          The last thing is, you have to add <trustLevel> tag in share point sites's web.Config file. You need to  set trust level to "WSS_Medium"

<trustLevel name="WSS_Medium" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_mediumtrust.config" />

Fig - (4) Setting Trust Level.

          Here you have completed all the required configurations !!!! Now open your share point site in browser and check for newly added page. In our case the link will be http://ServerName:PortNumber/CustomePage/FirstCustomePage.aspx

         If you have done all the changes as mentioned above you can see your page running fine in browser.

Happy Programming !!! 

7 comments:

Anonymous said...

very nice and quick too! One question though I get a message stating "The application attempted to perform an operation not allowed by the security policy" how do you recommend handling this error message in SharePoint?

Anonymous said...

To solve the above issue you must place the FirstCustomePage.aspx page in the _layouts directory instead of a directory at the same level as the bin (the rest of the steps are the same). One side note to use certain code from the SharePoint object model you must run the code with elevated privileges or you will get a permissions error when page makes a server request!

Anonymous said...

I appreciate your effort in integrating page into sharepoint site. But I think this is not a proper way to add aspx page into sharepoint site. Did you think that If deployment of site comes in picture, what will happen to this page, as this page is not in sharepoint content db. You have to take care of this page seperatly.

Anonymous said...

Thanks a Lot....It helped me in learning aspx page to SharePoint within no time.

Suman Paladugu

vfdvgf said...

if wow gold and maple story mesos wow gold

Anonymous said...

Thank you.

Anonymous said...

Hi,
Thanks boss,your blog is really excellent,I need small help,When i am doing add an aspx page to Sharepointserver.The page is opened in normal window.what should i do.please give me ur valuble reply