SPHttpUtility.UrlKeyValueEncode(string str)


Use this method to encode value and add it to QueryString (ex: you want to have a like that key=Failed to read Request Parameters, if you use this method it will be like that key=Failed%20to%20read%20Request%20Parameters

Solve SharePoint Debugging Session Terminated By IIS


This problem occurs if you set a breakpoint in a Visual Studio SharePoint solution, press F5 to run it, and then remain at a breakpoint longer than 90 seconds.

Error Message

The Web server process that was being debugged has been terminated by Internet Information Services (IIS). This can be avoided by configuring Application Pool ping settings in IIS. See help for further details.


By default, the IIS application pool waits 90 seconds for an application to respond before it closes the application. This process is known as “pinging” the application. To resolve this issue, you can either increase the wait time or disable application pinging entirely.

To access the IIS app pool settings

Open IIS Manager.

In the Connections pane, expand the SharePoint server node and click Application Pools.

On the Application Pools page, select the SharePoint application pool (typically “SharePoint – 80”) and then, in the Actions pane, click Advanced Settings.

To increase the wait time before IIS timeout, change the value of Ping Maximum Response Time (seconds) to a value larger than 90 seconds.

To disable IIS pinging, set Ping Enabled to False.

reference : http://msdn.microsoft.com/en-us/library/ee231594.aspx

Custom SharePoint Job Definitions


To Create Custom job definition follow the following steps:
1 – Create a new class inherit from Microsoft.SharePoint.Administration.SPJobDefinition
2 – Make this class public
3 – Add three public constructors which is the same of the parent for example:
public CustomJob(): base()
this.Title = “Custom Job”;

public CustomJob(string jobName, SPService service, SPServer server, SPJobLockType targetType) : base(jobName, service, server, targetType)
this.Title = jobName;

public CustomJob(string jobName, SPWebApplication webApplication): base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
this.Title = jobName;
4 – Override execute method which contain all the logic of the job
5 – Add new application feature
6 – Add Feature Event receiver to the new feature
7 – In activation receiver register your custom job for example
public override void FeatureActivated(SPFeatureReceiverProperties properties)
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
CustomTimerJob.CustomJob myJob = new CustomTimerJob.CustomJob(“New Job”,webApp);
SPDailySchedule schedule = new SPDailySchedule();
schedule.BeginHour = 1;
schedule.EndHour = 2;
myJob.Schedule = schedule;
8 – In feature deactivate remove your custom job