Just sharing some of my inconsequential lunch conversations with you... RSS  

Friday, November 21, 2008

The easiest HttpHandler ever!

Not that HttpHandler is hard to create, but it can get quite intrusive mainly because of configuration issues.

The ashx extension simplifies all this process. Here's all you've got to do:

namespace MyProject
{
using System;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for FederationLogin
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class FederationLogin : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
try
{
//
// set content type to jpeg
// TODO: consider changing to smaller footprint png version

context.Response.ContentType = "image/jpeg";

// dump image according to credential presence
context.Response.WriteFile(Credentials != null ? "SignedInOnFederation.jpg" : "NotSignedInOnFederation.jpg");
}

catch
{
//
// Oops, something went wrong: opt for a non-intrusive (but non-assertive)
// KISS approach: just assume no federation ticket was issued.
// Please note: no log is being issued.

context.Response.ContentType = "image/jpeg";
context.Response.WriteFile("NotSignedInOnFederation.jpg");
}
}

public bool IsReusable
{
get
{
return false;
}
}
}
}


This is a simple SignIn on federation button. But more about it later, I'm still on an NDA on this one.

IE 8 beta 2

You can find it at http://www.microsoft.com/ie8

<update>

Oops, I'm so embarrassed, I've got it since last August... oops...

</update>

Tuesday, November 11, 2008

Changing your SQL Server name

Cloning VM machine's is something we usually do, but SQL Server doesn't like it's machine's name to be renamed. Here's a cool one I didn't know of - I used to re-run the setup, it really didn't installed it again, just clean it up. But here's a better way:

sp_dropserver <old_name>
GO

sp_addserver <new_name>, local
GO


Now all we have to do is:




  • restart SQL instance


  • delete all logins associated with old machine's name


  • add them back



There you have it :)

Development Catharsis :: Copyright 2006 Mário Romano