Friday, August 10, 2012

Getting the SMTP name for Web app


In place of explicitly hardcoding the SMTP name in the SharePoint to send mail, its always better to get the SMTP configured for the Web App, so that in future if due to any reason its getting changes, there will not be any impact on the application


private string GetSmtpServer()
{
 SPWebApplication parentWebAppp = SPContext.Current.Site.WebApplication;
 if (parentWebAppp != null)
 {
   return parentWebAppp.OutboundMailServiceInstance.Server.Address;
 }
return string.Empty;
}

Wednesday, April 11, 2012

Issue by enabling HTTPOnlyCookies on sharepoint site

HTTPOnlyCookie is enabled by default for Authentication and Sessions cookies in ASP.NET 2.0 but not for manually issued cookies. To enable it for manual issued cookie we need to add following in the web.config.
<httpCookies httpOnlyCookies="true" />

Once we enable the HTTPOnlyCookie on the SharePoint, few things like the default approval workflow for the list will give problem while enablind. We can notice it will add one extra parameter(Infopath_Sentinel=1) in the URL querystring. I am not sure what it is used for, but we cannot create the workflow.

So to avoid this we need te make sure the HTTPOnly cookie need not be enabled from the web.config.

Tuesday, April 10, 2012

Reading RSS feed

Recently while reading the data from the RSS feed, we faced an issue with the RSS not getting updated because of the Header cache. After analysis we found that its because of the caching on client server, we are not able to get the updated data.

To solve this we have tried many options, but the easiest option is to embed the querystring with GUID, which will make sure its always the fresh request.

Following is the sample code

string sSiteUrl = sFeedURL;
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.Encoding = System.Text.Encoding.UTF8;
Guid guid = Guid.NewGuid();
sSiteContent = webClient.DownloadString(sSiteUrl+"?guid="+guid.ToString());
webClient.Dispose();

Tuesday, November 15, 2011

Changing Site Collection URL

There are no out-of-the-box command in SharePoint to rename a site collection URL, to change the URL we need to recreate the site collection with new URL and restore the previous site collection
Source site Collection URl : http://sharepointdev/sites/Mritunjay
Source site Collection URl : http://sharepointdev/sites/mritunjay

Steps to Change the site collection URL
  1. stsadm –o backup –url http://sharepointdev/sites/Mritunjay -filename backup.dat
  2. stsadm –o deletesite –url http://sharepointdev/sites/Mritunjay
  3. stsadm –o restore –url http://sharepointdev/sites/mritunjay -filename backup.dat

Tuesday, October 4, 2011

Cannot complete this action as the Secure Store Shared Service is not responding. Please contact your administrator.

While configuring the performance point 2010 I got the following issue
Cannot complete this action as the Secure Store Shared Service is not responding. Please contact your administrator.

After trying many approaches, I found the solution
1. Make sure the SecurityTokenServiceApplicationPool is running.
2. Go to System Settings -> Manage services on server
Following services should be enabled
PerformancePoint Service
Secure Store Service
Claims to Windows Token Service
3. Go to Application Management -> Manage service applications
4. Check the Secure Store is started
5. Go to App-pool and make sure the the associated App pool is running
6. Reset the IIS






Tuesday, August 2, 2011

Execute query with string

Today, I got a strange requirement to have the query as query string to execute, and tried various ways and found that the simplest way to do this is

Declare @temp Varchar(500)
Set @temp = ‘Select * From Employees’
Exec (@temp)

the above code will help us in adding or removing the clause from the query

Monday, July 25, 2011

FullTextSqlQuery Search Queries with URL

Recently I was working with Full Text SQL Search Queries and found a strange issue while filtering with the URL in the query. If the URL contains special characters its giving me the exception improper query.

My Old Query was
SELECT ArticleDate, URL FROM SCOPE()
WHERE CONTAINS(URL, 'http://mritunjay.com/sites/the site/docs/URLTest @/')

after few encoding I tried to embed the URL in the " I was able to get the correct output

SELECT ArticleDate, URLFROM SCOPE()
WHERE CONTAINS(URL, '"http://mritunjay.com/sites/the site/docs/URLTest !@$/"')