21 February, 2013

Code Blocks are not allowed in this file error in sharepoint 2010



Hello Everybody,
Today I worked on one critical issue which belongs to our development environment. We have migrated one web application from production environment to development for testing purpose. Migration has been successful but we were facing an exception while browsing the web application.

Error Message:
An error occurred during the processing.
Code blocks are not allowed
Troubleshoot issues with Microsoft SharePoint Foundation.

Server Configuration:
·         2 SharePoint Servers
·         SQL server 2008 R 2
·         Windows Server 2008 R2
·         SharePoint Version: SP2010

Troubleshooting done:
1.    Tried accessing the system pages i.e. settings.aspx, viewlsts.aspx etc. every system was opening fine without any issues. So the issue is with the home page only…
2.    Tried accessing the web part maintenance page, it opened without any issues. We closed the webparts which are present on the home page-just to make sure that there is no problem with the existing webparts. Checked the home page again but same issue.
3.    Tried changing the master page as were able to open the system pages (by appending _layouts/changesitemasterpage.aspx). We changed to different one as we are using custom master page. Checked the results again but same problem.
4.    Opened the site in SharePoint Designer 2010 and checked the status of master page as well as the home page. It was fine and without customization too.

Note: if you see any of these pages in customizable state then I would suggest you to take the backup and try ‘reset to site definition” option.

Obviously, next question will arise- what exactly it will do? Yes, it will reset your page to default state. It means you will lose your customizations. But issue will be resolved and you can customize the page again as per your requirements.

5.    Checked the windows application as well as SP logs (Location: \14\Logs). I would suggest you to analyze these logs before continuing your troubleshooting.

What is my observation\Understanding?
·         Code blocks are only processed for custom pages deployed in the root virtual directory of a site if the code it considered safe.
·         This code is considered safe only if the page is served directly from the file system. As soon as it becomes unghosted for any reason, the code is no longer considered safe and the error shown in the symptom occurs.

Resolution:
As our production web application was working without any issues so I compared the web.config of both the applications. Analyze the code line by line with the production web.config and that’s it. I found the one which was missing in the web.config that belongs to my development web application.

Note: I would suggest you to take a proper backup before making any changes in the web.config file.

What I did? What kind of entries I added in the web.config file?

Here we go:-
In you web.config, you need to search the tag name as “<PageParserPaths>”
Once you find that then make the following  entry:
<PageParserPaths>
    <PageParserPath VirtualPath="/apps/*" CompilationMode="Always"
              AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>
After adding this entry then IISRESET is mandatory.

Tried accessing the site and the issue has been resolved.

Happy SharePoint once again…

If you have any queries/questions regarding the above mentioned information then please let me know, Thank you.

20 February, 2013

Hide column on Newform.aspx. In SharePoint

Issue: Client reported that on newform.aspx page, there is one column which appear for awhile and then disappears.
Troubleshooting:
-          Checked if the column is custom created.
-          Checked if the column has its value hidden in the content type column setting.
-          Marked the column value to be required.
-          Saving the list as template without content and worked fine on the other site, gives issue on the same site.
-          Tried deleting the problem column form the problem list, its still disappears from the newform.aspx page.
-          Checked the list in SharePoint Designer to check if the newform.aspx page is customized. No customizations were implemented.

Resolution:
On further troubleshooting, we edited the new.aspx page and found two ‘content editor webpart’ each containing a Java script code.
Out these two codes one was like given below:
           
Where nth-Child is used as an argument to pass to the table and function to perform is hiding.
The 8th number is the column number in the newform.aspx page. Editing the page and changing the number equivalent to the number of the column would hide that column from the page.
Either changing the number to something to not equal to the column number or removing the code had resolved the issue.
Applies to:
-          SharePoint 2007
-          SharePoint 2010.
-          SharePoint Designer.  

Disk space mismatch than the actual size allocated on disk.

Issue: Today while doing our regular BAU of monitoring the server space. I have got a Tivoli alert which is configured to alarm you when there is low disk space. 
Issue was while looking at the drive space the total of 199 GB was showing as used space and total storage space occupied by files and folder was 58 GB on the drive.  Where is the rest of the space occupied. Strange….???
Troubleshooting:
-          Unhide the system hidden files. Not occupying the space.
-          Checked the file size of the files and folder stored. Not occupying the space.
-          Checked the Volume shadow copies of the all the drives. No disk is mounted to be used as Shadow copies. All drive status is set to ‘Disabled’.
Resolution:
Came across a very nice article which talks about the various ways to check if there is a mismatch in the drive space.
Step 6 from the above article was the resolution for my problem.
-          Running VSSADMIN LIST SHADOWSTORAGE to find out, which drive is having the total used space as a volume shadow copy.

-          132 GB of storage space was occupied by C Drive.
-          Limiting Maximum size of the storage area in Shadow copies had releases the space allocated.

Applies to:
Windows Server 2008
Windows Server 2003.

Problem Description: SharePoint shows network break/unknown error very frequently (on average 3 on 5 days in week. Client end up trying the file upload 4-5 times to do it (each iteration being of 10 min. each)


Problem Description: SharePoint shows network break/unknown error very frequently (on average 3 on 5 days in week. Client end up trying the file upload 4-5 times to do it (each iteration being of 10 min. each)
Error Message: Server request timed out. Please try again or the network connection with the server has been lost. Please try again.
Troubleshooting done:
ü  Checked how big the file is? It’s around 25 MB. We have upload limit of 100 MB in our farm.
ü  What is the name of the Library name?
ü  How is client trying to upload the file? Client was using both upload document” or “upload multiple documents” option for file upload on the site.
ü  Tried adding a entry in the host file and checked and no go.
ü  Removed the user from all people still the user gets all the options and is able to get to the option of upload, did not find the user in any DL.
ü  Added the use as a site collection admin still no go.
ü  Cleared the cache still the same.
ü  Added back the permissions removed of the user.
ü  Ran the office diags no go.
ü  It works from a different machine.
ü  On the other machine on the first document library it works always. On the second library it works sometimes.
ü  Cleaned the temp folder which was 680 MB and could upload the file for the first time, second, the transfer rate he experience in upload is about 20 kbps whereas other colleagues are able to transfer files to SharePoint at about 150+ kbps.
ü  Suggested client that transfer rate could also depend upon the network speed or the internet bandwidth. And local LAN support could assist him better in increasing the transfer rate.
ü  Tried uploading the 14 MB file from ‘Upload multiple file’ option. And waited for 10 Min and get error message ‘The network connection with the server has been lost. Please try again.’
ü  Noticed while uploading the file the transfer rate of the upload was 40 kbps, and client did notice the upload transfer rate as 150 kbps for his other colleagues.
ü  Network card is configures to run on 100 mbps.
ü  Tried to upload a little less sized file of 9 MB on another site. It also did take same amount of time.
ü  Working on another machine for the client doesn’t take much time to upload the file for one site.
ü  It seems it is related to the network bandwidth issue.

Resolution: Changing the LAN settings to be 100 mbps full duplex it makes the things working fine. It was set to 10 mbps something. To change the settings go to
My Computer (right click properties)&gt; Hardware &gt; Device Manager &gt; LAN settings.
Applies to: SharePoint 2007, SharePoint Server 2010.


General Procedure of Server Hardening


Below I have listed various resources for Server hardening:

Windows Server 2008 Security Baseline

The Windows Server 2008 Security Baseline is updated for Windows Server 2008 Service Pack 2 (SP2).  This updated product baseline provides:
·         Setting severity ratings, allowing you to quickly sort, prioritize, and apply Microsoft security and compliance recommendations.
·         Consolidated product baselines that eliminate EC and SSLF baseline components, and make viewing, customizing, and implementing your security and compliance baselines easier than ever!
·         New compliance-based settings groups allow quicker and easier compliance reporting and audit preparation, when used with the GRC management solution within System Center.

The Windows Hardening guides have been replaced with the corresponding Security guides.
The security guides for various OS and products are included within the Microsoft Security Compliance Manager http://technet.microsoft.com/en-us/library/cc677002.aspx
You can find each security guide under the “Attachments \Guides” section for each product within the Compliance Manager console.

Other security documents
- Threats and Countermeasures Guide: Security Settings in Windows Server 2003 and Windows XP

- Microsoft Baseline Security Analyzer (MBSA)

- Threats and Countermeasures Guide: Security Settings in Windows Server 2008 R2 and Windows 7

- Threats and Countermeasures Guide: Security Settings in Windows Server 2008 and Windows Vista

- Attack Surface Analyzer (beta)

- Microsoft Security Compliance Manager
 
- DoD recommendations on securing various OSs

SQL

Here is a SQL Hardening guide for Sharepoint Environments:

Microsoft  SQL Server 2008 R2 Best Practices Analyzer

IIS:

IIS 6.0 Webserver Hardening:

From what I understand IIS 7 does not have a hardening guide yet…
The following forum has really good information on IIS7 lockdown recommendations:

SMS IIS Hardening Checklist.

IIS7 Security PowerPoint  released by our EMEA team:

3rd Party considerations:
Due in part to the patching diligence of most organizations, we've seen these attacks shift from exploiting unpatched Microsoft vulnerabilities to targeting outdated 3rd party products.

 In particular Java VM and Adobe products have been heavily targeted:

- Our Malware Protection Center (MPC) details this in the following write-up:

 - Recommend upgrading any outdate Java JRE to the latest Sun Java Version (Latest Version)

- You can go to the following site to verify the version of Java on your system

 - Also recommend installing any Adobe updates from
  Adobe X reader (Latest)

-  Adobe Flash Player (Latest)

-  Other Adobe updates

- Also, Secunia has a patch management tool called Secunia Personal Software Inspector (PSI) that will scan and check for vulnerabilities in a variety 3rd party software.