Restrict Anonymous users from accessing custom Admin pages

 Restrict Anonymous users from accessing custom Admin pages..Use this snippet in page load where you want to restrict... 

SPUser user = SPContext.Current.Web.CurrentUser;
                if (user == null || string.IsNullOrEmpty(user.LoginName))
                {
                    Response.Redirect(SPContext.Current.Web.Url, true);
                }
                else
                {
//your code here...

}

Comments

Post a Comment

Popular posts from this blog

Sharepoint 2013 Script Editor web part CData for custom page layout using visual studio.

List attachment link in SharePoint 2013 search.

Bulk update and delete using SPservice in SharePoint