Hi,
Below is the code for event which on item adding redirects to Application page.
using (SPWeb owebsite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))
{
SPListItemCollection collitems = owebsite.Lists[properties.ListTitle].Items;
if(collitems.Count > 10)
{
properties.Cancel = true;
properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
string ErrorMessage = "Adding more items are prevented . Count = " + collitems.Count.ToString();
properties.RedirectUrl = "http://win-mq3esu10uuj/sites/km/_layouts/15/InductionNew/ExceptionPage.aspx?Error=" + ErrorMessage;
}
else
{
base.ItemAdding(properties);
}
}
The above code was working fine in last sharepoint 2010 project but in sharepoint 2013
while adding item i only get error "The server was unable to save the form at this time. Please try again." but its not redirected to the ExceptionPage.aspx application page