Xerratus
Happily stressed out, since 1974


 
Monday, August 20, 2007

So, for the past couple of weeks, while working on a project that involves integration with Community Server 2007 I've run into the annoying and ambiguous message "Unable to start debugging on the web server".



Now, I've set up IIS sites before and I know to check the usual suspects; app pool, Windows authentication, etc.  But with the tight deadline of this project, I just haven't had the time to research this one.  Googling this usually just brings up forums where "Unable to start debugging on the web server" is brought up that are run on Community Server.  Yeah, helpful.

So, today I need (stress the word NEED) to debug this application because the blog web service is not returning consistent data.  That's a whole other WTF, but for now we'll stick with the issue at hand; getting the damn thing to debug.

With that, I have to figure this out.  Within a few minutes I find myself in this forum which is telling me that it's my IIS is corrupt and that I have to uninstall everything .NET then reinstall it all.  Bullshit I say!  BULLSHIT!  So I continue to scroll down when I see a reply from a "David B" which simply says to change the debug attribute in the web.config to true.  YES!  Community Server distributes the SDK with this option set to false.  Damn, I need to remember this!

So, for those of you in the same boat, DO NOT reinstall IIS and everything .NET, just change the web.config to the following:

<compilation debug="true" defaultLanguage="c#">

Works like a charm.
Wednesday, August 15, 2007

Working on a project today that has some aspects that integrate with Community Server, I ran into a slight problem.  I needed to replace the submit resource link button for adding comments with an image button.  At first it sounded easy.  Just replace the <CSControl:ResourceLinkButton /> with an <asp:ImageButton />.  Not so fast, the compiler said.  The <CSBlog:WeblogPostCommentForm /> was looking for a link button that inherits from CSLinkButton.  Of course, the built in image button does not do that.  So my solution, create my own custom composite control that inherits CSLinkButton but generates a link button.

Here's how I did it:

First, create a new control in the CommunityServerControls20 project (anywhere is fine but I put it in a new folder called "Custom") and call it CustomImageLinkButton.cs.

Add the following code:

using System;
using System.ComponentModel;
using CommunityServer.Components;

namespace CommunityServer.Controls
{
    
public class CustomImageLinkButton : CSLinkButton
    {
        [
Bindable(true)]
        
public virtual string ImageUrl
        {
            
get
            {
                
object state = ViewState["ImageUrl"];
                
if(state != null)
                {
                    
return (string)state;
                }
                
return "";
            }
            
set { ViewState["ImageUrl"] = value; }
        }

        
protected override void OnPreRender(EventArgs e)
        {
            
base.OnPreRender(e);

            
if(!Globals.IsNullorEmpty(ImageUrl))
            {
                System.Web.UI.WebControls.
Image image = new Image();
                image.ImageUrl = ImageUrl;
                
this.Controls.Add(image);
            }
        }
    }
}

When you create the control in the UI and pass in an ImageUrl, the control creates an image object and adds it to the links control array.  That's it.

Here is the UI code in action:

<CSBlog:WeblogPostCommentForm ID="WeblogPostCommentForm1" runat="server">
    ... snip ...
    <FormTemplate>
         <div class="CommonFormArea">
             ... snip ...
            
<div class="CommonFormField">
                <br />
                <CSControl:CustomImageLinkButton runat="server" ID="btnSubmit" ImageUrl="http://localhost/project1/images/submit.jpg" ValidationGroup="CreateCommentForm" />
             </div>
        </div>
    </FormTemplate>
</
CSBlog:WeblogPostCommentForm>

Enjoy!


Wednesday, August 08, 2007

My wife just sent me pictures of newly delivered furniture today to my phone, which I forwarded to my gmail account, which I used to populate this entry.



Our new sofa for the entertainment room



The chaise lounge for the library (my fav)



Dining room table and chairs (the wifes fav)



Buffet that accompanies the dining room table

Technology.  I just can't remember life without the internet... and web enabled cell phones.

So, this morning I applied a performance & reliability update (KB938979) that is supposed to help with a known Vista hibernation issue.  I haven't put my laptop into hibernation to check it out yet but what I did find is that my volume, network and power icons are gone from the task bar.  The thing that I liked was that these were icons that I could have always displayed by selecting them in the properties dialog.  They wouldn't hide after inactivity, sometimes even after selecting them to show by default.  Well, I opened up the task bar properties and saw the following:



What gives?  Why are the system icons disabled?  I WANT to select them.  I WANT to see them.  I WANT to feel all warm and fuzzy inside knowing that they're there.

All I can say now is that I hope this hibernation issue is resolved.  If not, I'm uninstalling this update crap.

UPDATE: After not finding a resolution for this, I've uninstalled this update.  My system icons are back and that makes me happy.
Wednesday, August 01, 2007

In my years of programming, I've always found one thing that's been fairly consistent; developers love to put the baseUrl in the web.config.  While this is nice and works well good, it does pose it's problems especially in local development environments where the baseUrl isn't always the same.  One day a while back, I decided to write something that grabbed the baseUrl from the Request object.  It didn't take much time at all and works great. 

Today I needed to use it again for another project and thought I'd share while I had it open.

For those of you interested, here is the method I created:

private string GetBaseUrl()
{
    
HttpContext context = Context;
    
string url = context.Request.Url.AbsoluteUri;
    
string baseUrl = url.Replace(context.Request.Url.AbsolutePath, "") + context.Request.ApplicationPath;
    
    
return (baseUrl.EndsWith("/")) ? baseUrl : baseUrl + "/";
}

To use, simply place this into the application_start event:

this.Application.Add("BaseUrl", GetBaseUrl());

Now, to use from within your sites codebase you can access it as such:

string baseUrl = (string)Page.Application["BaseUrl"];

No web.config to worry about and works with different IIS settings when developers are working with the code.