views:

158

answers:

1

I'm trying to port an existing ASPX page, which is part of an existing web site, into a new Sharepoint site. The ASPX page is a relatively simple form with some server-side controls, the ability to email form submissions and "Captcha". The current website has the Newtonsoft.CaptchaControl dll registered in the bin folder. So what I need to do is:

  1. Port the ASPX page into the proper location within the content of a Sharepoint site

  2. Properly register the CaptchaControl dll with Sharepoint and link allow the ASPX page to utilize it

+1  A: 

Set up application page

The ASPX page would be called an 'application page' in SharePoint. You can copy the ASPX to the layouts folder under the "12 Hive". ("%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS"). It would then be accessible from any SharePoint site under {URL}/_layouts/CustomPage.aspx (e.g. http://site/_layouts/CustomPage.aspx or http://site/subsite/_layouts/CustomPage.aspx).

Add safe control entries

It looks like you know to place any DLL for your aspx page as well as CaptchaControl.dll in the bin folder for the SharePoint site under IIS. The DLLs must be signed with a strong name key. You also need to add the strongly-named signature of the DLLs to the SafeControls list in the web.config file for the SharePoint site. If you open up the web.config you'll see examples, e.g.:

<SafeControl Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
    Namespace="Microsoft.SharePoint" TypeName="*" Safe="True" />

Configure code access security

Assuming your controls actually do something, you need to mark them as trusted in the Code Access Security file that SharePoint uses. Change the trust level in web.config from WSS_Minimal to WSS_Custom. Go to "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\CONFIG" and copy wss_minimaltrust.config to wss_customtrust.config. Edit wss_customtrust.config and make new CodeGroup entries using the public key of your DLLs. For example:

<CodeGroup
    class="UnionCodeGroup"
    version="1"
    PermissionSetName="FullTrust">
    <IMembershipCondition
        class="StrongNameMembershipCondition"
        version="1"
        PublicKeyBlob="002400000480435694000000060200000024245452534131000400000100453261002888e278243eb86b47eea4be1b23451177126fb9c847085e66e895a64b148c675dabda94d9301f4886a0126887bcd067356affb16a5112baf3198525fc96c45f4178a6263e1a1132bb6c0a4cdaeaccd97b0d4ab42139585700c41e8481feff03e13f30bb0a10ffa7746770d144be94954b7a908fb9bb680ebe611f50f6db" />
</CodeGroup>

Note: This will make your DLLs fully trusted within the SharePoint web application. It is better practice to restrict permissions to those actually required.

Alex Angas