Sep 21

It is not the way to fight spams on blogs, but for professional look for websites, duplicate comments should not be allowed. This feature is common among most popular blogs and forums, so i bring this simple extension to add this feature to BlogEngine.

To enable this extension just upload it to your extension directory under App_Code.

The extension is attached with this post.

ValidateComments.cs (1,014.00 bytes)

Sep 12

YUI 3.0.0 From Yahoo!

Posted By Ahmed El-Kilani On 12 Sep 2009 3 Comments »

The Yahoo! next-generation JavaScript and CSS library, is a big step forward.
YUI team has improved the library; syntax is enhanced, API is more flexible and easy to use.

Featured Components:

  1. DataSource: YUI’s data abstraction layer provides a standard interface into data sets, regardless of the data’s origin (local, XHR, XSS, etc.) and format (JSON, XML, CSV, etc.);
  2. ImageLoader: ImageLoader allows you to defer the loading of images that aren’t in the viewport when the page paints, throttling bandwidth usage and improving performance;
  3. History: The History component gives you control of the brower’s back button within the context of a single-page web application;
  4. StyleSheet: StyleSheet makes it easy to create and modify CSS rules on the fly, allowing you to dynamically style page elements with fewer repaints.

More:
http://developer.yahoo.com/yui/3/

Sep 04

BlogEngine.NET SendMailMessage issue

Posted By Ahmed El-Kilani On 04 Sep 2009 3 Comments »
BlogEngine.NET is one of the best .NET blogs over there. I have changed to blogengine for its simplicity and themes support and customizability.
Sending mail from BlogEngine sometimes does not work. Why?
BlogEngine uses different email addresses as "Sender email" i.e "From", for example: the email of the comment poster is used as the sender notification email.
Most of the SMTP severs like godaddy only replay emails sent from only addresses hosted at the same domain as the blog is hosted, for security and spam-fighting reasons.

To fix this issue add the following to BlogSettings class under BlogEngine.Core:
/// 
/// Gets or sets the e-mail address notifications are sent from.
/// 
public string SenderEmail { get; set; }
Then we need to add the following node to settings.xml under BlogEngine.Web/App_Data
sendername@example.com
And finally a little modification in SendMailMessage method in Util class under BlogEngine.Core
/// 
/// Sends a MailMessage object using the SMTP settings.
/// 
public static void SendMailMessage(MailMessage message)
{
	if (message == null)
		throw new ArgumentNullException("message");

	try
	{
        //Override sender email which was set from contact or comment forms:
        MailAddress senderEmail = new MailAddress(BlogSettings.Instance.SenderEmail, message.From.DisplayName);
        message.From = message.ReplyTo = message.Sender = senderEmail;
		message.IsBodyHtml = true;
		message.BodyEncoding = Encoding.UTF8;
		SmtpClient smtp = new SmtpClient(BlogSettings.Instance.SmtpServer);
        // don't send credentials if a server doesn't require it,
        // linux smtp servers don't like that 
        if (!string.IsNullOrEmpty(BlogSettings.Instance.SmtpUserName)) {
		    smtp.Credentials = new System.Net.NetworkCredential(BlogSettings.Instance.SmtpUserName, BlogSettings.Instance.SmtpPassword);
        }
		smtp.Port = BlogSettings.Instance.SmtpServerPort;
		smtp.EnableSsl = BlogSettings.Instance.EnableSsl;
		smtp.Send(message);
		OnEmailSent(message);
	}
	catch (SmtpException)
	{
		OnEmailFailed(message);
	}
	finally
	{
		// Remove the pointer to the message object so the GC can close the thread.
		message.Dispose();
		message = null;
	}
}