Introduction
As all we know SharePoint is having an option to search a content through out the site. We can able to skip some sites in search crawling. Normally, we can do this manually in the site.
Goto Site Settings --> Search and Offline Availability and set option as you want.
Let see, How can we set this programmatically.
Code
var contextWeb = SPContext.Current.Web;
contextWeb.AllowUnsafeUpdates = true;
contextWeb.AllowAutomaticASPXPageIndexing = false;
contextWeb.ASPXPageIndexMode = WebASPXPageIndexMode.Never;
contextWeb.NoCrawl = true;
contextWeb.Update();
contextWeb.AllowUnsafeUpdates = false;