In this post we will discuss about how we can redirect a user to a Success page or Error page in SharePoint 2010.
You can also check my previous posts on Configure Claim Based Authentication in SharePoint 2010 [Solution here
], Single Sign-on in SharePoint 2010 [Read here
] and Create List from ExcelSheet in SharePoint 2010 [Read here
We can use SPUtility class to send user to success or error page. SPUtility class will be available in Microsoft.SharePoint.Utility namespace.
SPUtility.TransferToSuccessPage("Operation was completed", @"default.aspx", "", "");
You can pass any custom message you want. See figure below:
Exception ex = new Exception("An unexpected error has occurred.");
See the figure below for reference.