Open List attachments in new tab/window

Hello Floks,

Recently one my client is looking for solution in which all the list item attachment should be open in new tab or window as they have compare more than one files simultaneously.

There is a very easy solution to make it feasible. Open you List Edit/Disp Form and add below JavaScript inside it.

 $('#idAttachmentsTable a').attr('onclick','');
 $('#idAttachmentsTable a').attr('target','_blank');

Above code remove On Click event from all of the list attachment and add target as blank.

Enjoy.. 🙂 Happy Coading… 🙂 🙂

How to get list of running worker process using command prompt

In SharePoint, if you want to debug your code then you need to attached W3WP worker process in Visual Studio to start debugging. Generally, we are attaching all the worker process. By doing this all the SharePoint services goes in the debugging mode and your process takes more execution time then it generally takes. To avoid this we have to attached only worker process (W3WP) which is associated with our application.

To attach worker process we need to navigate Tools Menus > Attach Process or we can use short cut command i.e. Ctrl + P. It will open new window in which all the process are listed and we will find the w3wp process and attach all that process to start the debugging.

To find which w3wp worker process is associated with our application, we need to go to IIS Manager which is very long process and other one is using Command Prompt.

  • Find associate process using IIS Manager

1. Open IIS Manager
2. Click on Worker Processes as displayed in below image.
3. It will display your application name as well as Process ID. By the use of Process ID you can attach only 1 process to debug your code.


In above process after every deployment you need to close the current Worker Process window and again open it to get it refresh so that it’s time consuming and hectic process.

  • Find associate process using Command Prompt

1. Open command prompt with Run as Administrator
2. Navigate to C:\Windows\System32\Inetsrv
3. C:\Windows\System32\Inetsrv> appcmd list wp to get all worker process along with Application Pool name. You will get result as below image.

This is very simpler method to get Process ID of your application while developing SharePoint custom code.

Enjoy 🙂 Happy Coading..:)

Clear SharePoint Designer Cache

Hi Floks,

Today I am going to explain how to clear cache of SharePoint Designer. By clearing SharePoint Designer Cache following things of SharePoint Designer will be wiped out.

  1. Site history which you open in SharePoint Designer in the past
  2. Credentials which you stored in SharePoint site
  3. Site folders which will be created while opening site in SharePoint Designer

Steps to clear SharePoint Designer Cache

  • Open Run


  • Open below listed path & Remove everything from the folder
    • %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
    • %APPDATA%\Microsoft\Web Server Extensions\Cache\


Now open SharePoint Designer, you can see all the history of we application which you opened in SharePoint Designer will be erased.



SharePoint URL shortcuts / URL of Pages which can be used for SharePoint Administrator

Below is the list of pages & their paths which can be accessed from URL :

Below listed URL’s works for SharePoint 2010 for SharePoint 2013 please add /15/after /_layouts.

  1. Add web parts to any page: /append ?PageView=Shared&ToolPaneView=2
  2. Create New Site Content: /_layouts/create.aspx
  3. Create New Site: /_layouts/NewsbWeb.aspx
  4. List Template Gallery: /_catalogs/lt/Forms/AllItems.aspx
  5. Master Page Gallery: /_catalogs/masterpage/Forms/AllItems.aspx
  6. Manage your Alerts: /_layouts/SubEdit.aspx
  7. Create New Alert: /_layouts/SubChoos.aspx
  8. Manage Site Collection Administrators: /_layouts/mngsiteadmin.aspx
  9. Manage Sites and Workspaces: /_layouts/mngsubwebs.aspx
  10. Manage People: /_layouts/people.aspx
  11. Manage User Permissions: /_layouts/user.aspx
  12. Modify Navigation: /_layouts/AreaNavigationSettings.aspx
  13. Modify Site Navigation: /_layouts/SiteNavigationSettings.aspx
  14. Recycle Bin: /_layouts/AdminRecycleBin.aspx
  15. Site Directory: _layouts/SiteDirectorySettings.aspx
  16. Save Site as Template: /_layouts/savetmpl.aspx
  17. Site Settings page: /_layouts/settings.aspx
  18. Create New Web Part Page: /_layouts/spcf.aspx
  19. Site Template Gallery: /_catalogs/wt/Forms/Common.aspx
  20. Site Column Gallery: /_layouts/mngfield.aspx
  21. Site Content Types: /_layouts/mngctype.aspx
  22. Site Content and Structure Manager: /_layouts/sitemanager.aspx
  23. Site Usage Summary: /_layouts/SpUsageWeb.aspx
  24. User Alerts: /_layouts/sitesubs.aspx
  25. View All Site Content: /_layouts/viewlsts.aspx
  26. Web Part Gallery: /_catalogs/wp/Forms/AllItems.aspx
  27. Web part maintenance mode: /append ?contents=1 to the URL of the page
  28. Open the page in Edit Mode – In Address bar, Type: “javascript:MSOLayout_ToggleLayoutMode();” or  “javascript:MSOTlPn_ShowToolPane(’2′);” in the Address bar
  29. Add Web Parts Pane: ?ToolPaneView=2
  30. Display all content types of sites: /_layouts/mcontent.aspx
  31. Sign as different User: /_layouts/closeConnection.aspx?loginasanotheruser=true

WCF – The maximum string content length quota (8192) has been exceeded while reading XML data

The DataContractSerializer in WCF serializes objects to XML Streams. There is a size (length) limitation on these streams. They are restricted by default to 8k (8192 bytes).

While this helps in avoiding Denial of Service (Dos) attacks, it is an inconvenience for several service operations that DO return LARGER than 8k size objects. The result set from a single query returned by a WCF service could constitute one such large object. When this happens, the WCF run-time throws an exception:

The maximum string content length quota (8192) has been exceeded while reading XML data.

To work around this limitation, certain web.config values need to be tweaked – both, on the client web.config (Web.Config file of application which consume WCF Service/Web Service) as well as the server(Web.Config file of Web Service/WCF Service). Just having a client SEND a large message – without the server web.config configured to ACCEPT the message, will just throw a different exception. One needs to tweak both in conjunction as described below in Server Web.Config file:

Snapshot of Server Web.Config file:

<binding name="basicHttpConfiguration" maxBufferSize="2147483647"
<readerQuotas maxStringContentLength="2147483647" />

Server (Web Service/WCF) Web.Config file summary

  • maxStringContentLength
  • maxBufferSize
  • maxReceivedMessageSize

Client Web.Config file:

<binding name="RequestProcessorBinding" receiveTimeout="00:30:00"
sendTimeout="00:01:00" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
contract="MyWcfServiceReference.IMyService" name="BasicHttpBinding_IMyService" />

Client Side Web.Config Summary

  • maxStringContentLength
  • maxBufferSize
  • maxBufferPoolSize
  • maxReceivedMessageSize
  • maxStringContentLength

How to change Default Home Page : SharePoint

I frequently get questions on changing the home page or using another page as the home page:

  • Can I have three (or four or five or…) columns in the default home page?
  • Do I have to use the new wiki home page in my Team Site?
  • I want to test a new home page design, but I don’t want to lose the existing home page… (just in case you know…)
  • How can I use a page from my wiki library as my home page?

Below are four ways to set another page as your home page: (all four work for both 2007 and 2010)

  • From Site Settings (If the publishing features are enabled)
  • From SharePoint Designer
  • From code / API
  • From PowerShell

The first two can be used by Site Owners, the second two can only be used for developers and administrators

Important Notes for all methods:
Make sure all of your users have at least read access to the new home page, and if in a library that you have it checked in and published.

1.   If the Publishing features are enabled for a site then: (From Site Settings)

Click on Site Action  =>  Site Setting  =>  Welcome Page


2.   From SharePoint Designer:

Right-click the new page and click “Set as Home Page”.  (For SharePoint 2007 this only appears to work from SharePoint                    Designer if the file is in the root of the site. I.e. the same place as default.aspx.)


3. From Code / API

Please follow the following link for code.

4. Via PowerShell

$site = Get-SPSite http://yourserver/sites/yoursite
$web = $site.RootWeb (or $web = $site.OpenWeb("yoursubsite") 
$folder = $web.RootFolder 
$folder.WelcomePage = "SitePages/home.aspx" 
(or $folder.WelcomePage = "default.aspx") 
(or $folder.WelcomePage = "Shared%20Documents/mycustomwebpartpage.aspx") 

If you need any type of help please let me know on following email id : Thank You.

Configure RDLC Report with ReportViewer : SharePoint 2010

I have worked with SharePoint 2010 Foundation and found the RDL(C) report is not configured automatically.  To run a successfully report I applied the following changes in SharePoint web.config file. To make sure the configuration works for reporting just put a reportviewer control inside a webpart/page and try to access the page. First of all make sure you have intalled “Microsoft Report Viewer 2010 Redistributable Package”. You can it from here.

Here I am going to list down steps to configure report viewer setting for SharePoint.

1.   First find the following line in AppSettings and comment it out as shown below:

 <!--<add key="ReportViewerMessages" value="Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />-->

2.   By default session is disabled in SharePoint. Enable it by ensuring an entry like below inside <system.web>.

<sessionState mode="InProc" timeout="60" />

3. Enable session at page level by setting the enableSessionState to true of <page…..> tag inside system.web.

<pages enableSessionState="true" enableViewState="true" enableViewStateMac="true" validateRequest="false" ……………………=""

4. SharePoint disable the default session module inside the <system.webserver>\modules tag. To enable the module comment out the following line inside <system.webserver>\moudles as shown below:

<!--<remove name="Session" />-->

Now if you try to put a reportviewer control in webpart/page, you will find a message as below:


If you got/find above error message while accessing the report page then you are on right track. Please continue with following steps:

5. Add the following tag inside system.web\httphandlers section

<add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

6. Add the following line in the system.webserver\handlers

<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

7. Comment out the following line in the system.WebServer\httphandlers (If Exists)

<!--<add name="ReportViewerWebControl" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />—>


That’s it..!! Error will be resolved now. Enjoy..:)

Session state has been disabled for ASP.NET. The Report Viewer control requires that session state be enabled in local mode

Solution for following error:Image

I had to install SharePoint Foundation 2010 for a new project. They needed a native Web Part, and the name of this was Report Viewer control

But a received a strange correlation-ID error and I could not open anymore my site. so I opened ULSVIEWER and got a stranger error: Session state has been disabled for ASP.NET. The Report Viewer control requires that session state be enabled in local mode

So I made some researches on internet and found always the same PowerShell Command:

Enable-SPSessionStateService ( “The only way to install ASP.Net Session State is through PowerShell using *-SPSessionStateService. [Enable | Disable | Get | Set]-SPSessionStateService” )


Reference-1  Reference-2   Reference-3

The problem is that when I followed the directions for enabling session state using powershell, I could not find the cmdlet. I spent a ridiculous amount of time trying to figure this out since I had the correct powershell snapin, but I could not find that cmdlet.


To resolve this issue you need to change at 2 places.

     1. Do Following changes in your sharepoint web.config file

  • You need to edit the web.config file of the SharePoint application. Open your web.config and add the httpModules.

  • In the <system.web> section, find the <httpModules> element and edit it like the following:

  • <httpModules> <add name = “Session” type=”System.Web.SessionState.SessionStateModule” /></httpModules>

  • You also need to find the element tag <pages> (also under the <system.web> element) and look for the attribute called enableSessionState and set it to true if it is currently false. Save and close the web.config file.


     2. Now another thing is you need to add modules in IIS7

  • You should then open the IIS 7 manager, and select your web application.

  • Open the modules applet under the IIS section.

  • Click “Add Managed Module” in the right hand panel.Enter a name for the module, I chose “SessionState”, you can pick what you like, but I suggest something related to session state and then in the lower box, select the entry for:

  • System.Web.SessionState.SessionStateModule, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Made an IISreset, and test again. you can now add your WebPart Report Viewer control to your site.

How to send requrest after executing Response.End() statement

Once I have to create a custom search on list item for some of the item fields and then it can be exported to excel. I successfully developed a custom visual web part which display only those record which fulfilling the search criteria and is transferred to excel. But then i face one problem that first time when i search the record and export it to excel it works fine. But for the second time my request is not sent to server because of using Response.End() function to avail the user to download the exported record in excel file.

So following is the solution for the same. Add below JavaScript in  your web part design page.

<script type="text/javascript">
        _spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper = true;

and append following code in your page load event.

System.Web.UI.ScriptManager scriptManager = System.Web.UI.ScriptManager.GetCurrent(this.Page);

Please replace this.btnToExport with your button or your control on which you handle click event to export it to excel.