title: C# - How to set SharePoint permissions for user under subsite not Root level
body: <p>I'm trying to add permissions for a user that is under a subsite in SharePoint. I was able to successfully set the permissions for the user on the root level, but I am not sure how to approach the problem for a lower level subsite. Below is what I have at the moment but it crashes although it shows no error building in VS. Any ideas would be great</p>
  
  <pre><code>        foreach (SPWeb subSite in spSite2.RootWeb.GetSubwebsForCurrentUser())
          {
              if (subSite.Name == "templates")
              {
                  Console.WriteLine("\nTEMPLATES SITE");
                  Console.Write("\nApplying 'Read' permission to App_user Account");
                  spRoleAssignment = new SPRoleAssignment(SPContext.Current.Web.Users[appUserAccount]);
                  spRoleAssignment.RoleDefinitionBindings.Add(SPContext.Current.Web.RoleDefinitions["Read"]);
                  SPContext.Current.Web.RoleAssignments.Add(spRoleAssignment);
                  SPContext.Current.Web.Update();
                  Console.ForegroundColor = ConsoleColor.Green;
                  Console.CursorLeft = Console.BufferWidth - 16; Console.WriteLine("Applied");
                  Console.ForegroundColor = ConsoleColor.Gray;
              }
          }
  </code></pre>