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.
No comments:
Post a Comment