Thursday, October 31, 2013

Disabling mobile page redirection in SharePoint 2013

SharePoint 2013 is supported for mobile devices and it will detect the request from mobile devices according to the request it will changes the URL of the page automatically. Mobile view is different from the desktop view in SharePoint. SharePoint is having complete different controls for mobile pages.

We are having Microsoft.SharePoint.MobileControl namespaces for mobile pages which inherits from System.Web.UI.MobileControls namespace. Whenever mobile device request is detected, it will redirected to mobile devices optimized version pages. By default these pages will be located in “_layouts/mobile” folder. By default the team site redirects mobile home page “_layouts/mobile/mblwp.aspx”. We can customize the home page for the mobile devices.

We can restrict redirection for mobile pages, by adding the below lines in web.config file System.web for SharePoint web application

<browserCaps>
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile,            Version=2.0.0.0, Culture=neutral, PublicKeyToken=d04e4d2a43f43d3e"/>
<filter>isMobileDevice=false</filter>
</browserCaps>

Wednesday, October 30, 2013

SharePoint custom workflow Error – This view cannot be displayed because the number of lookup and workflow status columns exceeds the threshold”

While working with SharePoint custom coding on lists, I got an error saying that “This view cannot be displayed because the number of lookup and workflow status columns it contains exceeds the threshold..”

After googling in to the issue, I have found the solution in this post. We can see this problem due to lookup columns value exceeds the SharePoint environment configuration value. When tis error occurs, SharePoint web services will refuse to return the documents. By increasing “List View Lookup Threshold” value, we can fix this error.
We can increase the limit in SharePoint central Administration by using following steps,

Navigate to application Management in SharePoint Central Administration and click on “Manage Web Applications” link.



Select the web application to increase threshold value, Click on “Resource Throttling” in General Application Settings in the ribbon.


In List View Lookup Threshold” section we can specify the maximum number of lookup that Specify the maximum number of Lookup, Person/Group, or workflow status fields that a database query can involve at one time. Change the value to bigger and click on OK to save the settings.

Tuesday, October 29, 2013

Cache profiles in SharePoint

SharePoint adds caching mechanism with output caching that is available in ASP.Net 2.0. It contains Cache profiles that we can name and apply the pages and page items, content types and levels of scales in the development environment.

By using cache profiles we can control the quality level of the output caching in SharePoint site. It will allow or disallow site owners to choose their cache profiles. We can manage the user access permissions to SharePoint depending on the access to the site. Output cache renders the page, same way for users in same right. After creating and deploying the cache profile, any change that affects the cache profile will affects all the content access of the profile.

To enable output cache settings,
Navigate to Site Settings menu and click on Site Collection Output cache in Site Collection Administration section


In the Output Cache Settings page, check Enable output cache check box to enable output cache.



Select cache profile for anonymous from Anonymous Cache Profile list. This applies for anonymous users access for a site in Site Collection. To choose authenticated users from Authenticated Cache profile list. This will apply for authenticated users to access in a site in the Site Collection. To display additional cache information on the site collection pages that including the date and time of the page rendered earlier select Enable debug cache information on pages.

To create new caching profiles,
Navigate to Site Setting menu in SharePoint site. Click on Site collection cache profiles in Site Collection Administration.


Click on New to Create new cache profile.


Provide Title, Display Name, Description for Cache profile in Title, Display name Display Description columns. To ensure that all items in the cache are security trimmed check “Perform ACL Check” check box. To enable the cache, check “Enabled” check box. Enter Duration to specify the number of seconds to keep the cached version available. Check for changes will validates the page requests that the site has and to flush the cache. If we unchecked this system will not check for the updates on the sites.



Vary by custom parameter, Vary by HTTP Header and Vary by User Rights will specifies the values described in the ASP.Net cache policy. By selecting Vary by User Rights, we can ensure that users will have effective rights on the SharePoint site that having on the cached page. Select any value in Cacheability drop down  Select the policies to allow the authenticated users and page layout designers to apply authenticated scenarios. Check “Allow Writers to View Cached Content” to not allowing people with edit rights to cache their pages.


Thursday, October 24, 2013

SharePoint SEO and Robots.txt

Many of public sites developed in SharePoint that are configured to allow anonymous access with restriction that should not be indexed by any search engines. We can prevent that by placing robots.txt file in the root of our SharePoint site.

Robots.txt file is text file that we can place in SharePoint site root level to indicate the search engines that should not crawled or indexed. It is not a mandatory rule for search engine to follow Robots.txt instructions but generally search engines are designed to obey robots.txt commands.

Robots.txt file location should be in the main directory of site that should be easily available for search engines. Because search engines should not search for the entire site for robots.txt file.  They look main directory of site, if it is not find there, then it will assume that current site will not have any robots.txt file. So that it will index everything in the site.

To create a robots.txt file, create a text file with following kind of text,
User-Agent: *
Disallow: /_Layouts/
Disallow: /SiteAssets/
Disallow: /Lists/
Disallow: /_catalogs/
Disallow: /WorkflowTasks/

Here “User-agent” means the section that applies all robots and “Disallow” tells robot that should not index in the site. Save the file as “robots.txt” .Add file in root of the site by using SharePoint designer. Open designer and add the file in All files tab. By adding the file in All files tabs robots.txt file will be located in root site.


To add robots.txt file to the site, navigate to Application Management in SharePoint central Administration, Define managed path for the web application to configure.
In the Path text box, provide the URL as “/robots.txt” and type as Explicit inclusion. Click on Ok to save the settings.


Do IISRESET. If we have permissions problem, Provide read permissions for “Everyone” to robots.txt file.
We can add robots.txt file to a site using following Power Shell commands.

$file = [system.io.file]::ReadAllBytes("robots.txt full path");                                          
$siteToAddFile = Get-SPSite "Site to add the robots.txt"; 
$siteToAddFile .RootWeb.Files.Add("robots.txt", $ file, $true);  

Wednesday, October 23, 2013

Sharing with Everyone in SharePoint 2013

Sharing with everyone option will help users to share without depending on permissions. That will be applicable for “All authenticated users” and “all users in tenant” in the sense “Everyone” and “Everyone excluding external users”.

By default sharing option will be available for SharePoint 2013 site created using existing template. But when we create a site using site template or a solution, try to share the site we’ll get an error saying that “This web template required that certain features be installed, activated and licensed. The following problems are blocking application of the template:” 

After googling some time i have found the solution from office blog URL. All authenticate users is now Everyone. So these settings will not be automatically updated. We have to activate a feature to fix the issue. To activate the feature we need to run the Power Shell commands below,

$siteURL= “URL Of the Site Collection to activate the feature” 
$site = Get-SPSite $ siteURL$site.Features.Add([System.Guid]"10F73B29-5779-46b3-85A8-4817A6E9A6C2")


Here 10F73B29-5779-46b3-85A8-4817A6E9A6C2 is the GUID of the feature to activate.