There are two parts to this task, designing the page and making changes to web.config to make use of the page.
Here is the first part:
We`ll create a page of some custom layout in Pages document library of the default site. In my case I will be using a feature to create all the pages so here is my Feature.xml file:
<?xml version=”1.0″ encoding=”utf-8″?>
<Feature xmlns=”http://schemas.microsoft.com/sharepoint/”
Id=”2AD06D98-581B-4408-AEC1-79DC366F0A35″
Title=”Provisions Login Page”
Description=”Provisions Login Page”
Version=”1.0.0.0″
Scope=”Web”
Hidden=”TRUE”
ActivateOnDefault=”FALSE”
AlwaysForceInstall=”TRUE”
ImageUrl=”">
<ElementManifests>
<ElementManifest Location=”SignIn.aspx.xml” />
</ElementManifests>
</Feature>
Next, we`ll define the actual SignIn.aspx.xml like this:
<?xml version=”1.0″ encoding=”utf-8″?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>
<Module Name=”SignIn” Url=”Pages” Path=”">
<File Name=”SignIn.aspx” Url=”Default.aspx” Type=”GhostableInLibrary”>
<Property Name=”ContentType” Value=”GeneralPage” />
<Property Name=”Title” Value=”Sign In” />
<Property Name=”PublishingPageLayout” Value=”~SiteCollection/_catalogs/masterpage/SignInLayout.aspx, Sign In;” />
<AllUsersWebPart WebPartZoneID=”MiddleZoneLeft” WebPartOrder=”1″>
<![CDATA[
]]>
</AllUsersWebPart>
</File>
</Module>
</Elements>
Above we defined our page to use SignInLayout.aspx you probably want to have custom layout for this page.
I also have an empty webpart area defined here within this area <![CDATA[ ]]> in here you probably want to put a webpart that will render the login controls.
My login control will be a regular new ASCX file in my solution that will have the contents of
12 hive\TEMPLATE\LAYOUTS.
Change page definitions to be control definitions in your new control. Also, this is where you add your special markup if required - things like DIVs wrapping around the controls or error messages. This will really depend on how you want your login box to look like.
Now, you have an
ascx and need to make it into a webpart. I usually use
SmartPart from CodePlex which takes your ascx file and reders it within it.
Once you install SmartPart into your environment - or use WSP if it`s a part of your solution - just pre-populate .webpart of the SmartPart with your control properties.
Now after all of the steps in my last post have been completed and you deployed your custom login page to the pages folder, here is what you do next:
In a web.config of your SharePoint website modify the loginUrl value of the following path: configuration/system.web/authentication/forms to be the page of your choice. This will take care of the necessary redirect.
Keep in mind, the fact that your users will be redirected to the custom page doesn`t mean they can access it - so ensure annonymous access to the site.
Cheers!
Yaroslav Pentsarskyy, Microsoft MVP
Blog: www.sharemuch.com