Skip to main content

Posts

Showing posts from September, 2008

Incorrectly Storing Objects In The ASP.NET Session

In an effort to keep this from happening to someone else, I figured I'd write about it today. I'm surely not the first person to ever write about this, so I'm not claiming to have found something novel. I've personally never written a web application that needed to utilize the ASP.NET Session object, but apparently other folks have not learned that.

Anyway, the following chunk of code was being used to store a reference to the "domain object" currently being viewed/edited.

namespace Your.Web
{
/// <summary>
/// Summary description for ContainerBase.
/// </summary>
public class ContainerBase : Page
{
public virtual IDomainObject DomainObject
{
get
{
if (Session["DomainObject"] != null)
{
return (IDomainObject) Session["DomainObject"];
}
else
{
return null;
}
}
set { Session["DomainOb…

The Overuse of the StringBuilder class in .NET

So this friend of mine Adam wrote this post today. The main point of the post I love, as it correctly abstracts the creation of the query string behind a class and away from the rest of the code that is consuming the query results. Why I'm writing this post is that while his post was not directly having to do with the StringBuilder class, IMHO, he is displaying what I believe is indicative of the over zealous use of the StringBuilder class.

For the sake of convenience, this is how he wrote it:

private static string BuildDefaultViewQuery()
{
var builder = new StringBuilder();
builder.Append("<Where>");
builder.Append("<Eq><FieldRef Name='DefaultView' /><Value Type='Boolean'>");
builder.Append("1");
builder.Append("</Value></Eq></Where>");
return builder.ToString();
}

This is how I would have written the guts of this method:

private static string BuildDefaultViewQuery()
{
return String.Forma…

SharePoint/MOSS 2007 External Third Party Desktop Application Integration

Today I was presented a scenario where a client wanted to integrate a non-Microsoft Office desktop application into their Microsoft Office SharePoint Server 2007 (MOSS) environment such that documents created/edited in that app and stored in MOSS document libraries were able to be directly opened into that app ready for editing, and ultimately saved back to the document library.

Since Google'ing the answer to this scenario took me more than 30 seconds to find, here is the answer.

Inside SharePoint - Integrating "Office" Applications
http://technet.microsoft.com/en-us/magazine/cc565180.aspx

And here are some more useful links:

Text Files, Associations, and SharePoint
http://weblogs.asp.net/bsimser/archive/2005/01/24/359911.aspx

Sharepoint Beef #3 : Melt-in-your-mouth Native Apps support issue resolved
http://weblogs.asp.net/dburke/archive/2004/01/13/58330.aspx

SharePoint.OpenDocuments Control
http://msdn.microsoft.com/en-us/library/ms454230.aspx

How to enable the “Edit in Microsoft …