When I was adding an in-line code into master page I was getting the following error.
An error occurred during the processing of /sites/<collection>/SitePages/Welcome.master. Code blocks are not allowed in this file.
The fix is add the following code to the web.config of the web application which hosts the site collection.
<PageParserPath VirtualPath="/sites/site/_catalogs/masterpage/Welcome.master" CompilationMode="Always" AllowServerSideScript="true">
The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>).
The above code I moved out of the “<form runat=”server”…” code and the below code inside the required location.
Now the page is rendered properly.
While I was modifying SharePoint’s master page to put an inline code, I was constantly redirected to SharePoint Error Page “An unexpected error has occurred”.
After spending nearly an hour to get a clue from EventLog and other sources, I found out that by adding the following config codes to web.config of the web application where the site collection resides, we can see the ASP.NET error page with detailed information.
<SafeMode MaxControls=”200″ CallStack=”true”>