If you want to retrieve all available search contexts for the web site collection where your application is initiated then you can use the following code to get it
SearchContext searchContext = SearchContext.GetContext(ServerContext.Current);
If you want to retrieve all available search contexts for the web site collection where your application is initiated then you can use the following code to get it
SearchContext searchContext = SearchContext.GetContext(ServerContext.Current);
If you want to hide the identity of the user who responded your survey, just perform the following steps:



Now, check your survey and you will see that all user identity fields like Created By and Last Modified By will just show *** instead of the original user name.
Several times I have been asked about the way Sharepoint calculates the rank of a document in document search. Although, it is based on a complex probablistic algorithm developed by Microsft Researcher, following are some simple tips to know the background of search ranking and how to tune the search results. Please note, these tips are not an authentic statements from Microsoft, instead they are my observations and knowledge gained from other fellow Sharepoint experts.
According to Microsoft on Technet in this article
Ranking depends on:
Keeping the above points in mind, following observations have been made as mentioned in this blog
If you are getting “Unable to connect publishing custom string handler for output caching“ error in your event log then it is because of a custom web service you have installed on your Sharepoint server. Reason for this error is that you have a web part on your portal page which use the custom web service. Now, since Sharepoint uses output caching for the web pages to optimize the rendering experience and fast delivery of unchanged pages therefore, publishing infrastructure of Sharepoint tries to access the web service through your web part and due to any issue in your service, it starts generating this error.
Anyway, cutting a long story short, here is the solution:
Edit the web.config of custom web service (Please do not edit your Sharepoint Web application web.config) and make sure you have following under httpModules node which is located under system.web node.
<remove name=“PublishingHttpModule“ />
Following is a utility function which you can use to upload a file programmatically in SharePoint document library. It has two parameters. First is the source file path and second is the target document library path.
Following is an example call to this function:
UploadFileToDocumentLibrary(@”C:\test.txt”, @”http://home-vs/Shared Documents/textfile.txt”);
and here is the function
public static bool UploadFileToDocumentLibrary(string sourceFilePath, string targetDocumentLibraryPath)
{
//Flag to indicate whether file was uploaded successfuly or not
bool isUploaded = true;
try
{
// Create a PUT Web request to upload the file.
WebRequest request = WebRequest.Create(targetDocumentLibraryPath);
//Set credentials of the current security context
request.Credentials = CredentialCache.DefaultCredentials;
request.Method = “PUT”;
// Create buffer to transfer file
byte[] fileBuffer = new byte[1024];
// Write the contents of the local file to the request stream.
using (Stream stream = request.GetRequestStream())
{
//Load the content from local file to stream
using (FileStream fsWorkbook = File.Open(sourceFilePath, FileMode.Open, FileAccess.Read))
{
//Get the start point
int startBuffer = fsWorkbook.Read(fileBuffer, 0, fileBuffer.Length);
for (int i = startBuffer; i > 0; i = fsWorkbook.Read(fileBuffer, 0, fileBuffer.Length))
{
stream.Write(fileBuffer, 0, i);
}
}
}
// Perform the PUT request
WebResponse response = request.GetResponse();
//Close response
response.Close();
}
catch (Exception ex)
{
//Set the flag to indiacte failure in uploading
isUploaded = false;
}
//Return the final upload status
return isUploaded;
}
To debug your custom application pages located in layouts folder, perform the following steps:
<compilation batch=“false“ debug=“false“>


If you are using Sharepoint 2007 to manage and display your reports then there is a big chance you may be using Reporting Services in Sharepoint Integrated mode. You may have noticed that reports run slower in Sharepoint integrated mode as compared to native mode. This is because of the calls to Sharepoint object model in integrated mode. To improve the performace Microsoft has released some optimizations in Service Pack 3 of SQL Server 2005 which reduces the number of calls to object model and increases the overall response time and performace.
Happy New Year to all readers and best wishes for 2009!