Tuesday, October 25, 2011

Using HTTPContext object Redirect Page from EventHandler

We need to display custom page redirection after adding list item.
We have to implement Synchronous event handler for above list because we can get HttpContext in Synchronous event handler & redirect to custom page using SPUtility.Redirect method.
See the below code for redirect custom page after adding list item. 
public class SyncEventReceiver : SPItemEventReceiver
    {
        HttpContext current;

        public SyncEventReceiver() { current = HttpContext.Current; }

        /// 
        /// An item is being added.
        /// 
        public override void ItemAdding(SPItemEventProperties properties)
        {
            base.ItemAdding(properties);

            SPSite oSite = new SPSite(properties.SiteId);
            SPWeb oWeb = oSite.OpenWeb(properties.RelativeWebUrl);
            SPList oList = oWeb.Lists[properties.ListId];

            //Set Enable Event Firing to False for disable reoccurence of events.
            this.EventFiringEnabled = false;
            
            SPListItem newItem = oList.Items.Add();
            //add item to list (you can add custom code here)
            newItem["Title"] = properties.AfterProperties["Title"].ToString();
            newItem.Update();

            //Set Enable Event Firing to True
            this.EventFiringEnabled = true;

            //redirect it to your new destination like newly provisioned sub site or any other page you want.
            SPUtility.Redirect("http://localhost/pages/default.aspx", SPRedirectFlags.Default, current);

        }

}
Happy Coding...!!!

Difference between Synchronous and Asynchronous events

Synchronous Events

  - Fire “before” the actual events
  - You can get HttpContent
  - You can display error message
  - You can cancel the event.
  - Synchronous methods ending with “ing” like itemadding, itemupdating itemdeleting.




Asynchronous Events
  - Fire “after” the actual events
  - You cannot get HttpContent
  - You cannot display error message
  - You cannot cancel the event
  - Asynchronous methods ending with “ed” like itemadded, itemupdated, itemdeleted etc.


Happy Coding...!!!

Thursday, October 20, 2011

Size limitation in MOSS 2007

SharePoint Object's Size limitation in MOSS 2007  

SharePoint Object                                                     Limits   
Site collections in a web application                      50,000

Sites in a Site collection                                    250,000
Sub-sites nested under a Site                                2,000
Lists on a Site                                                     2,000
Items in a List                                              10,000,000
Items in View                                                      2,000
Field Type in a list                                                  256
Documents in a Library                                    2,000,000
Documents in a Folder                                           2,000
Maximum document file size              2GB (by default 50MB)
Documents in an Index                                   50,000,000
Search Scopes                                                     1,000
Search Scopes in a Site                                           200
User Profiles                                                   5,000,000
Template size                                   10,000,000 (default)


Happy SharePointing...!!

Thursday, October 13, 2011

Identify Worker Process (w3wp.exe) in IIS 6.0 and IIS 7.0 for Debugging in SharePoint

It is very deficult to identify perticular SharePoint web application's worker process in IIS 6.0 and 7.0 because there are somy web aplication running on SharePoint Farm.


How to attach worker process?
we can go to Tools > Attach Process or use shortcut key Ctrl +P.
 Identify Worker Process in IIS 6.0

  • Start > Run > Cmd
  • Go To Windows > System32
  • Run cscript iisapp.vbs
You will get the list of Running Worker ProcessID and the Application Pool Name in IIS 6.0.


Identify Worker Process in IIS 7.0
From IIS 7.0 you need you to run IIS Command Tool ( appcmd ) .
  • Start > Run > Cmd
  • Go To Windows > System32 > Inetsrv
  • Run appcmd list wp
This will show you list worker process that is running on IIS 7.0 in the similar format of IIS 6.0

Happy Debugging...!!!