Take the 2-minute tour ×

I want to redirect using to another page after item added, main point is to redirect user to another page on item adding(item should be added first) or item added.


class ClassName: SPItemEventReceiver { HttpContext current; public ClassName() { current = HttpContext.Current; }

public override void ItemAdded(SPItemEventProperties properties)

        if (IamRightItem(properties))
            string webAppUrl = string.Empty;
            using (SPSite site = new SPSite(properties.SiteId))
                webAppUrl = site.WebApplication.GetResponseUri(SPUrlZone.Default).AbsoluteUri;

            if (!string.IsNullOrEmpty(webAppUrl))
                string redirectLink = string.Format("{0}{1}{2}{3}{4}", webAppUrl, "my/page.aspx", "?Action=abcAction", "&URL=", properties.WebUrl);
                SPUtility.Redirect(redirectLink, SPRedirectFlags.Trusted, current);

This code works for ItemUpdating but not for ItemAdded, why not :S

share|improve this question

4 Answers 4

up vote 0 down vote accepted

I have faced this issue before. After making the ItemAdded event synchronous, I was able to get the HttpContext but still the redirection was not happening. I solved it by doing the following workaround:

1) Use the ItemAdding Event (You have the HttpContext in it)

2) Add the item through code in the ItemAdding event itself.

3) After the item has been added, redirect using the SPUtililty.Redirect method.

Here is the sample code:

        HttpContext currentContext;  

        public CustomEventReceiver()
               currentContext = HttpContext.Current; 

        public override void ItemAdding(SPItemEventProperties properties)  

            SPList oList = properties.List;  

            this.EventFiringEnabled = false;  

            SPListItem newItem = oList.Items.Add();  

            this.EventFiringEnabled = true;  

            SPUtility.Redirect("http://server/redirectionPage.aspx", SPRedirectFlags.Default, currentContext);  

share|improve this answer
But it saying that Context is null. –  Grzegorz Z Nov 6 '12 at 8:46
Make sure that you are using the ItemAdding event and not the ItemAdded event. –  Vardhaman Deshpande Nov 6 '12 at 9:16

Here is an answer to a very similar question asked on SharePoint.StackExchange:

Redirect from ItemAdded event

share|improve this answer
my question is not a duplicate @ title as I couldn't find anyone mentioning SPUtility.Redirect in question link you provided, anyway thanks :) –  Muhammad Raja Nov 5 '12 at 14:05
Oh, I see... did you try making the event Synchronous? That way I believe you will have an HttpContext available and you will be able to use SPUtility.Redirect... –  Amadeo Gallardo Nov 5 '12 at 14:11
yup I got httpContext available and I am able to do it for item adding and updating. –  Muhammad Raja Nov 5 '12 at 14:15
I updated my question :) –  Muhammad Raja Nov 5 '12 at 14:28

It doesn't work because updated is asynchronous and called outside of the clients context.

You can create this using item updating, for after the updating event has occured, litterly doing a redirect on "Updated" but inside "Updating".

As I said before if you look for a tutorial on how to do this typing in "sharepoint Redirect for itemupdated using itemupdating" into google you will find plenty of tutorials on how to achieve this.

share|improve this answer

Is there any chance to redirect from Item Adding, but only once when Adding are finished. I tried many times., but Sometimes I got a error of Ribon, and sometimes I only updatet one record:

share|improve this answer
I am not sure if your asking me or telling me lol –  Muhammad Raja Nov 5 '12 at 15:35

Your Answer


