Apr 8, 2010

Hide View All Site Content on SharePoint Site

At times we need to hide certain things on the master page based on the user profile.

You might be finding blogs where people are coding or making these components invisible or commenting or deleting to hide them, Instead the method mentioned below is the correct way of doing the following:

  • hide View all site content
  • hide bread crumbs
  • hide My Links
  • hide My Site
  • hide help
  • hide left navigation

Highlighted below in the screen shot (logged in as site administrator):


Instead, simply open the master page using SharePoint Designer and using the split view
as shown below in the screenshot highlight the desired component to hide, in the example below i am using "My Site"


Now, lets add few lines to hide "My Site"

<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ManageSubwebs">


<SharePoint:DelegateControl ControlId="GlobalSiteLink1" Scope="Farm" runat="server"/></td>

</Sharepoint:SPSecurityTrimmedControl>

as shown below:

Now login as the Site Administrator and some other account like site members.
Notice the difference, the My Site is gone.

Logged in with site member account


Code only when necessary!

keywords: SPSecurityTrimmedControl

Apr 5, 2010

SharePoint Performance (IIS Http Compression and content expiration)

SharePoint Performance improvement by using IIS Http Compression and content expiration

Sites will be simply faster

Implemented http compression and content expiration, on IIS hosting the SharePoint sites and the page load time decreased to 3 seconds from around 6+ seconds.

To Improve SharePoint Site performance, one of the tweak you need to do is Http Compression at IIS Level

Benefits:

  • Effective bandwidth utilization, Conserve traffic and server resources
  • Faster transmission between Client/Server
  • Compress Static files, Compress Application response files (dynamic compression)

Performance Metrics

Before and after Implementing Http Compression on the Server Farm, following baseline metrics needs to be collected:

* CPU Usage under certain load or at certain times during the business hours
* Memory Usage under certain load or at certain times during the business hours
* Server Response time (Http Watch/ fiddler can be used)
         - This will help in making a decision, whether we can apply the dynamic compression or not.

Enabling HTTP compression,

1. In IIS Manager, double-click the local computer, right-click the Web Sites folder, and then click Properties.

2. Click the Service tab, and in the HTTP compression section, select the Compress application files check box to enable compression for dynamic files.

3. Select the Compress static files and Compress application files check box to enable compression for static/dynamic files.

4. In the Temporary directory box, click Browse to locate a directory. The directory must be on the local drive of an NTFS–formatted partition.

5. Under Maximum temporary directory size, click a folder size option.

6. Click Apply, and then click OK.


Static file is compressed, and it is cached in this temporary directory until it expires, or the content changes.

By default following files are compressed for Static compression: .txt, .htm, and .html

Dynamic files are compressed at runtime, means on demand when they are accessed by the end user. This means each time the file is being accessed the server CPU is under load.

By default following files are compressed for Dynamic compression: .exe, .dll, and .asp

Implementing compression (editing the Metabase.xml)

- Including certain file types

Static File Types > xml, rdf, css, js

Dynamic File Types > aspx, xsn, asmx, cgi

- level of compression

set to “9” should be changed to find the appropriate value based on the environment CPU utilization

On the WFE server look for Metabase.xml, located in the following directory: c:\windows\system32\inetsrv

Open the file and look for the following tags and replace it with the one given below:

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"

HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"

HcCreateFlags="0"

HcDoDynamicCompression="TRUE"

HcDoOnDemandCompression="TRUE"

HcDoStaticCompression="TRUE"

HcDynamicCompressionLevel="9"

HcFileExtensions="htm

html

xml

css

txt

rdf

js"

HcOnDemandCompLevel="9"

HcPriority="1"

HcScriptFileExtensions="asp

cgi

exe

dll

aspx

asmx

xsn"

>

</IIsCompressionScheme>

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"

HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"

HcCreateFlags="1"

HcDoDynamicCompression="TRUE"

HcDoOnDemandCompression="TRUE"

HcDoStaticCompression="TRUE"

HcDynamicCompressionLevel="9"

HcFileExtensions="htm

html

xml

css

txt

rdf

js"

HcOnDemandCompLevel="9"

HcPriority="1"

HcScriptFileExtensions="asp

cgi

exe

dll

aspx

asmx

xsn"

>

</IIsCompressionScheme>

<IIsCompressionSchemes Location ="/LM/W3SVC/Filters/Compression/Parameters"

HcCacheControlHeader="max-age=86400"

HcCompressionBufferSize="8192"

HcCompressionDirectory="%windir%\IIS Temporary Compressed Files"

HcDoDiskSpaceLimiting="FALSE"

HcDoDynamicCompression="TRUE"

HcDoOnDemandCompression="TRUE"

HcDoStaticCompression="TRUE"

HcExpiresHeader="Wed, 01 Jan 1997 12:00:00 GMT"

HcFilesDeletedPerDiskFree="256"

HcIoBufferSize="8192"

HcMaxDiskSpaceUsage="99614720"

HcMaxQueueLength="1000"

HcMinFileSizeForComp="1"

HcNoCompressionForHttp10="FALSE"

HcNoCompressionForProxies="FALSE"

HcNoCompressionForRange="FALSE"

HcSendCacheHeaders="FALSE"

>

</IIsCompressionSchemes>


* Ignore br tag

NOTE:

-- Cannot edit or save the IIS metabase.xml file
To edit the IIS metabase file without stopping IIS, you must enable Edit-While-Running.

Procedure:

- To enable metabase edit-while-running using IIS Manager

- In IIS Manager, right-click the local computer, and then click Properties.

- Select the Enable Direct Metabase Edit check box.

Instead of editing “metabase.xml”, we could use the following command but it doesn’t seem to work quite well.

cscript.exe adsutil.vbs …


Enabling Content Expiration for Client (Browser) Caching

In the IIS Manager, right click on the website and goto properties as shown below

One you have the settings as shown above, i.e.

- Enable content expiration checked mark

- Expire after should be set to around 30 days or based on application

- Under Custom Http Headers should have the following via edit

- An example of a Cache-Control server-response header is

o Cache-Control: max-age=3600

o Cache-Control: max-age=3600, must-revalidate

The must-revalidate attribute speeds up the caching process by rendering the repeated download of entire pages or objects unnecessary. If the data's freshness is unknown, the browser can contact the server to determine whether an update has occurred. If no changes to the object have occurred, the browser uses the cached copy.

§ Time is in seconds

Restart the IIS before testing the performance for your sites and comparing the baseline metrics.



NOTE You should consider testing the impact of compression levels and monitor the CPU utilization and potential impact to your Web servers. Generally, a compression level between 7 and 9 provides optimum performance


Testing:

Open the site using IE and enable the recording in the httpWatch, you should see something like following when navigating to home page (default.aspx):

Also look at the content in the next screen shot below:



Validate content expiration for pages other than some like default.aspx as shown below:

NOTE: At last but not the least, The above procedure needs to be implemented on all Web Front End (WFE) servers in the SharePoint Farm

For other performance tips follow SharePoint Performance Tuning

Apr 4, 2010

Office 2007 Ribbon

User Interface: Content Area Utilization (Office 2007 / Browser / ...)

In Office 2007 to get more content area make the ribbon hide when not in use, by right clicking on the top menu bar and choose "Minimize the Ribbon"

People who really use Office 2007, seems to realize that it has much better User Interface then previous Office versions.


Most of the web sites are standard for resolution 1024 x 784, to make sure all the viewers can browse them with the optimum content area utilization on the screen. As the screen sizes are increasing and some people tend to use higher resolution, we do have some area left, on the left and right inside the browser as the blank vertical rectangle.

Why not utilize the screen area by the floating toolbars or application? Maybe Windows Sidebar, ...

The Office 2007 story of Ribbon link

Apr 1, 2010

Add aspx page to SharePoint WebPart

When developing webparts in sharepoint we are limited in various ways, unleash the complete power of asp .net / visual studio by creating asp .net user controls and wrapping it in a webpart.

Objective: Encapsulate asp .net user control (.ascx) in a webpart, with complete wsp deployment.

WebPart The above visual studio solution will work as a template to quickly create the asp .net user control and wrap it inside a webpart.

Steps Use the template (source code link at the bottom of this blog post) and create asp .net user control webpart for SharePoint.

1) Open Visual Studio

2) Create Asp .Net Web App Project

Click Here to download the Visual Studio 2005 Web Application Project Preview (RC1) link,


3) Delete Default.aspx

4) Create a folder/file structure similar to



5) Copy files as shown below



6) Strong sign the key under properties

7) Change the namespace in all the .cs and ascx files in the project and also modify the properties of the solution as shown below

8) Copy the contents of the following file from the downloaded project template to the project you are creating


Files are:
CreateSolutionPackage.cmd
JQueryWebPartDemo.ddf
Manifest.xml
Elements.xml
Feature.xml
Main.cs
JQueryWebPartDemo.dwp
WebUserControl.ascx
WebUserControl.ascx.cs

Change the namespace, solution id (new guid), public key token (in further steps down), feature id (new guid) in all the above files

Names are kept similar to make sure; the replacement is easy across the files

9) Build the project and go to the bin folder

10) Use "Visual Studio Command Prompt" (Start >> Microsoft Visual Studio 2010 >> Visual Studio Tools >> Visual Studio Command Prompt (2010))

11) OR In case you aren't using the VS Command prompt, you can locate sn.exe at %ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\sn.exe

12) sn -T "C:\Documents and Settings\seimossadmin\Desktop\sp.test.wp\sp.test.wp\bin\sp.test.wp.dll"

and update the public key token in all files as required

9) Web Part file, the highlighted portion is public key token of the dll



10) The part in red box should be modified (similar to web.config safecontrol entry)


11) Change all guid’s like solution, feature

12) Under Properties> Build


17) Build the Project


18) Go to the folder where you have setup.exe in the project folder

19) Change the setup.config.exe for correct wsp name and solution id.

20) Run CreateSolutionPackage.cmd

21) Run Setup.exe and install.

22) Make sure wsp timestamp is the latest


You Tube Link:

1) Implementation Doc

2) VS 2005 Doc



Download the user control webart source code or example link,

Happy Coding ...

App pool recycle or IISReset and Running Warmup Script

IIS Application Pool Recycle: Is Warmup script accessing home page only enough?

IIS App pool generally gets recycled once a day, to make sure the end user access to site in terms of  performance doesn't drastically degrades, we need to have caching as well as warmup script setup correctly.

FACT:
Warmup script should hit the most frequently accessed pages of the sites instead of just accessing the site collection or home page.

REASON:
So that after the app pool recycle / iisreset the cache is created again and subsequent access of the site pages are retrived from the cache as applicable, instead of building the cache and slowing down the pages access further after the iis reset / app pool recycle.

Pages