SharePoint Redirect Page WebPart Based on Current User

In this hint, I explains How to create a SharePoint Redirect Page WebPart that redirect to specific page if the current user is not belong to a specific SharePoint security group by following the mentioned steps below :

  • Create A new SharePoint Solution using Visual Studio.
  • Add a new Visual Web Part.
  • In load function add the following code
if (!SPContext.Current.Web.SiteGroups["groupname"].ContainsCurrentUser)
  SPUtility.Redirect("url", SPRedirectFlags.Default, HttpContext.Current);

Enjoy 🙂

See also


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s