Friday, August 26, 2011

A HttpModule wasn't required after all...

A HttpModule wasn't required after all...

All that was needed was one fuction (method) and a simple if statement:

    private bool CheckHeaders( string forThis )
    {
      bool found = false;
      foreach ( string s in Request.Headers )
        if ( s.Contains( forThis ) )
        {
          found = true;
          break;
        }
 
      return found;
    }
 
    public ActionResult Index( string memberName )
    {
      if ( Request.Browser.IsMobileDevice || CheckHeaders( "iPhone" ) )
        return Redirect( string.Format( "~/Mobile/Index/{1}", memberName ) );
      
      // rest of this mehtod isn't being shown.
      }

And that's all for now. I did see a new way to generate site passwords with tons of entripy today and I'll be working on a more automated implementation of that next.

No comments:

Post a Comment