Wednesday, July 11, 2007

SharePoint 2007: using ASP.NET server side code in your pages

This is fairly undocumented piece of information which I have got from this blog

I havn't tried it myself, so I cannot gaurantee its completeness. I am posting it

here for the sake of interest and community .....

In the web.config file in the Sharepoint virtual directory contains the following section:

<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">

By default the node <PageParserPaths> is empty. You can add <PageParserPath> nodes to specify the

virtual paths where you want to allow server side scripts:

<PageParserPath VirtualPath="/pages/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true"/>

Where CompilationMode is one of the following values:


The page should always be compiled (default value)


ASP.NET will not compile the page, if possible.


The page or control should never be dynamically compiled.

I assume that the AllowServerSideScript and IncludeSubFolders flags speak for themselves.

Be careful with the virtual paths you specify in your PageParserPaths. Anyone that can modify or add a page to the virtual path can insert code that will be executed server side with no restrictions.

A good location to specify as a PageParserPath is the location where you store your masterpages, for example /_catalogs/masterpage. You can now add server side script to your masterpages, which makes it available in all pages using this masterpage.

<PageParserPath VirtualPath="/_layouts/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true"/>

1 comment:

Anonymous said...

Oi, achei teu blog pelo google tá bem interessante gostei desse post. Quando der dá uma passada pelo meu blog, é sobre camisetas personalizadas, mostra passo a passo como criar uma camiseta personalizada bem maneira. Se você quiser linkar meu blog no seu eu ficaria agradecido, até mais e sucesso. (If you speak English can see the version in English of the Camiseta Personalizada. If he will be possible add my blog in your blogroll I thankful, bye friend).