| John's profileJohn BarshingerPhotosBlogLists | Help |
|
November 17 Precompile your ASP.NET applicationI just made a ton of changes to the app I am working on and I wanted some way to hit every page to see if there were compiler errors on any of the aspx pages so I can fix them before manually testing each page. This can be done with the following command:
Run "cmd", cd to your preferred asp.net version, then run the aspnet_compiler command from that directory to compile the aspx pages in your app.
> cd C:\Windows\Microsoft.NET\Framework\v2.0.50727
> aspnet_compiler -c -p "C:\Projects\SupportSiteDev\SupportSite" -v / "c:\temp\staging"
The publish command inside VS2005 probably does something similar but I like using the command line version.
You could take the results in the staging directory and deploy that to your web site but I still like deploying real aspx files instead of stubs because sometimes you can make a real quick fix by just a tiny change to an aspx file which will immediately take effect. November 03 How to set file or directory permission in ASP.Net 2.0 C# (ACLs)I couldn't find much help online about setting directory permissions via C# so I came up with the following code to do it. This code does directory acls but doing files are very similar. Also, removing ACLs can be easily extrapolated by a few changes to this code.
class DirectoryPermissions
{ protected string directoryPath; public DirectoryPermissions(string directoryPath)
{ this.directoryPath = directoryPath; } public bool ACL_Exists(FileSystemRights desiredFilesystemRights, string GroupOrAccountName)
{ bool retValue = false; DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);
DirectorySecurity directorySecurity = directoryInfo.GetAccessControl(); NTAccount groupOrAccount = new NTAccount(GroupOrAccountName);
foreach (FileSystemAccessRule fr in directorySecurity.GetAccessRules(true, true, typeof(NTAccount)))
{ if ((fr.AccessControlType.Equals(AccessControlType.Allow)) && (fr.FileSystemRights.Equals(desiredFilesystemRights)) && (fr.IdentityReference.Equals(groupOrAccount))) { retValue = true; break; } } return retValue;
} public void AddACL(FileSystemRights desiredFilesystemRights, string GroupOrAccountName) { DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath); DirectorySecurity directorySecurity = directoryInfo.GetAccessControl(); FileSystemAccessRule directorySystemAccessRule = new FileSystemAccessRule(
new NTAccount(GroupOrAccountName), desiredFilesystemRights, InheritanceFlags.None, PropagationFlags.NoPropagateInherit, AccessControlType.Allow); directorySecurity.AddAccessRule(directorySystemAccessRule);
FileSystemAccessRule childrenSystemAccessRule = new FileSystemAccessRule(
new NTAccount(GroupOrAccountName), desiredFilesystemRights, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow); directorySecurity.AddAccessRule(childrenSystemAccessRule);
Directory.SetAccessControl(directoryPath, directorySecurity);
} } |
|
|