Modifying directory permissions with Web Deployment

The new VS2010 Web Deployment model is very powerful.  It allows you to setup all your configuration and then use one-click publish to load your web application (or just the diffs) up to your server.  Scott Hanselman gave a great talk on this at MIX that I highly recommend — http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx

Under the covers, this is all using MSDeploy which adds all sorts of power to run commands, set ACLs, etc.  Put exactly *how* to do this is not documented very well and I spent many a frustrating hour working on one simple task.  How do you make the web deploy process grant the Application Pool Identity access to a modify a specific directory?  Since the built in deployment resets all the permissions to Read-only, you have to figure this out or you have to manually change it every time.

Continue reading

MailTo in a GridView

Just a little tip since I had to Google it.  How do you make a column in a gridview show an e-mail address as a link that does a mailto:?

image

image

You’d think you could do a HyperLink column, but for some reason it doesn’t like the colon in the URL.  So instead you make a Bound Field and control the output to render the Anchor tag:

            <asp:BoundField DataField=”Email”
               
HeaderText=”Email”
               
DataFormatString=”&lt;a href=mailto:{0}&gt;{0}&lt;/a&gt;”
               
HtmlEncodeFormatString=”false”
               
SortExpression=”Email” />

Working with Login, Roles and Profiles

I just spent a lot of time coming up to speed on Membership and how to hook it into SQL Server.  I wanted to capture some notes and links…

 

A good overview of the different pieces: http://aspalliance.com/articleViewer.aspx?aId=743&pId=-1

Information on how to configure membership so a help desk can reset/retrieve passwords: http://mishler.net/PermaLink,guid,ea65afc0-2970-46f1-9412-4b57bbd906f4.aspx

ScottGu’s blog about adding Login, Roles, and Profile to ASP.NET 2.0 in only 24 lines of code: http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx

By default, custom Profile fields are saved in the aspnet_Profile table in a property bag approach, with the names also having some metadata on them.  This doesn’t work well if you need to do queries against that data.  A better approach is to use the SQLTableProfileProvider available from the Microsoft Sandbox here:  http://www.asp.net/downloads/sandbox/table-profile-provider-samples/  Unfortunately the code has a lot of comments and possible “to do” items in it, but a lot people seem to be using it and it seems stable.  The downloaded code has SQLTableProfileProvider depending on SQLStoredProcedureProfileProvider, but those two functions can just be copied over (somebody got lazy and created a dependency).  Note that any table you create needs to have a

The tooling support in Visual Studio for Profiles only works for Web Sites, not Web Applications.  This means you can’t say Profile.MyField.  You can either create your own custom code for it or just call Profile.GetPropertyValue(“MyField”) and Profile.SetPropertyValue(“MyField”,”MyValue”)  http://msdn.microsoft.com/en-us/library/aa983476(VS.80).aspx (look under “Converting Profile Object Code”)

Detailed tutorial about Membership, Roles, and Profile: http://www.4guysfromrolla.com/articles/120705-1.aspx