Guide to making a private BlogEnginge Blog

Feb 16, 2009 at 4:42 PM
Hi guys,

Here are the changes that I have made to BE - enabling it to be a "logon" only blog.

BlogEnginge.Core:

Filename: HttpHandlers/FileHandler.cs
 /// <summary>

    /// Sets the content type depending on the filename's extension.

    /// Lazze: New content type ".wmv" x-ms-wmv for better support

    /// external Windows Media Player

    /// </summary>

    private static void SetContentType(HttpContext context, string fileName)

    {

      if (fileName.EndsWith(".pdf"))

      {

        context.Response.AddHeader("Content-Type", "application/pdf");

      }

      else if (fileName.ToLower().EndsWith(".wmv"))

      {

        context.Response.AddHeader("Content-Type", "video/x-ms-wmv");

      }

      else

      {

        context.Response.AddHeader("Content-Type", "application/octet-stream");

      }

    }

Filename: Controls/BasePage.cs
Function: OnLoad

    // Lazze: To avoid error when running protected website

      try

      { // If the login page is being requested, don't add link to blog.js since

        // the file may be unavailable until successful logon

        if (!this.Request.AppRelativeCurrentExecutionFilePath.ToLower().Contains("login"))

          AddJavaScriptInclude(Utils.RelativeWebRoot + "blog.js");

 

      }

      catch { }

<!--EndFragment-->

BlogEngine.web:
Filename: Global.asax

/// <summary>

  /// Added By Lazze Ziden

  /// Makes the authentication Ticket pass the HTTP boundry

  /// making playing of WMV files in external player possible

  /// when site is protected by Login

  /// </summary>

  /// <param name="source"></param>

  /// <param name="e"></param>

  void Application_PreSendRequestHeaders(Object source, EventArgs e)

  {

    HttpApplication app = (HttpApplication)source;

    HttpCookieCollection cookies = app.Context.Response.Cookies;

 

    if (cookies != null)

    {

      foreach (string name in cookies)

      {

        HttpCookie cookie = cookies[name];

        if (cookie.Name.Equals(FormsAuthentication.FormsCookieName, StringComparison.OrdinalIgnoreCase))

        {

          cookie.HttpOnly = false;

          break;

        }

      }

    }

  }

<!--EndFragment-->
Filename: Web.config

<authorization>

  <deny users="?" />

</authorization>   

 

    <authentication mode="Forms">

      <forms timeout="129600" name=".AUXBLOGENGINE" protection="All" defaultUrl="default.aspx" slidingExpiration="true" loginUrl="~/login.aspx" cookieless="UseCookies" />

    </authentication>

<!--EndFragment--><!--EndFragment-->

<!--EndFragment-->Good luck!

Regards,

 Lazze