The best place to start is the CRM sdk.
Download it here:
http://www.microsoft.com/en-nz/download/details.aspx?id=40321
after unzip/install you can find the core code for portals here:
C:\SDK\Solutions\PortalBase
and even better, here C:\SDK\Walkthroughs\Portal
the explanation is here:
http://msdn.microsoft.com/en-us/library/gg695790.aspx
I Hope I could help. If I have answered please mark as 'Answer'. If was just helpful, please vote. Thanks and happy coding! Bruno Lucas, http://dynamicday.wordpress.com/