In this blog, we will see how to remove Share option from SharePoint site programmatically as well as manually.
Share option can only be for the normal users, while Site Collection Administrators and owners will still be able to see this option.
To remove Share option manually
Go to Site Settings –> Site Permissions –> Access Request Settings (from ribbon)
Uncheck the check box for allowing access request and click OK.
Shareoption
To remove Share option from the code:
Add the following references:
Microsoft.SharePoint.dll
Add the following namespaces:
Using Microsoft.SharePoint:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Microsoft.SharePoint;
- namespace ConsoleAppRemoveShare
- {
- class Program {
- static void Main(string[] args) {
- SPSite site = new SPSite(“http:
- SPWeb web = site.RootWeb; web.RequestAccessEmail = “”; site.Dispose();
- }
- }
- }