A simple HTMLHelper for displaying Gravatars

by Milad 2. November 2009 20:44

Practically, The whole world knows about Gravatar(Globally Recognized Avatar).
I wanted to use this awesome service in one of my ASP.NET MVC applications, So I went to it’s documentation to see what should I do. [Well there is a great HTMLHelper in order to perform this, but I have a point!]

The big thing in constructing a Gravatar URL is how to get a string’s hexadecimal MD5 Hash. [as you may or may not know, you can do lots of stuff with MD5 Hash of anything!]
So … This is the answer to this question:

Function GetHash(ByVal text As String) As String
        Dim myhash As MD5CryptoServiceProvider = New MD5CryptoServiceProvider()

        Dim hashed = _
            myhash.ComputeHash(System.Text.UTF8Encoding.UTF8.GetBytes(text))

        Dim sb As StringBuilder = New StringBuilder()

        For Each b In hashed
            sb.Append(b.ToString("x2"))
        Next

        Return sb.ToString()
End Function

Tags: , , ,

ASP.net | Computer | Internet | Programming

A few tips about ASP.net MVC

by MiladKDZ 2. May 2009 11:49

I started my first project with ASP.net MVC 2 days ago and I find it so much Interesting.

But I faced some Problems in it and I immediately found solutions using Google! (Thanks to MVC Community folks)

I also discussed writing a Helper method for HTML File Input Control in MVC with Dear Mahdi .

The most noticeable thing with MVC is the clean HTML that you get in runtime! Web development is so much fun with ASP.NET MVC ;-)

Tags: , ,

ASP.net | Computer | Programming

Enumerables

by MiladKDZ 6. March 2009 11:56

Just a little note!

The ExecuteQuery() Method from DataContext class, returns an instance of IEnumerable.
If you wanna determine if your Enumerable Instance is empty or not(Maybe you have performed a search operation using LIKE operator), you can use this piece of code:

YouEnumerableName.Equals(Enumerable.Empty<YourType>())

Tags: , ,

ASP.net | Computer | Programming

ASP.net File Upload Control

by MiladKDZ 24. February 2009 00:22

Well I'm working on a boring project but I'm learning too much! For example:

ASP.net's File Upload control has a 4MB  file length limit by default. [Basically every HTTPRequests should be less than 4MBs in an ASP.net Application by default]
So ... To overcome this limit, you can add this tag to your web.config file:

<httpRuntime maxRequestLength="4096"/>

Where you can replcace "4096" with any length in KBs.

µ

Tags: , ,

ASP.net | Computer | Programming

Some handy links for ASP.net MVC

by MiladKDZ 14. February 2009 22:10

Tags: , ,

ASP.net | Computer | Programming

ASP.NET Themes in Visual Studio

by MiladKDZ 22. July 2008 06:00

I love ASP.NET's ability to manage site themes and I've been using them for like a year. But I've always had a big problem! I couldn't see my themes in Visual Studio designer!

So I Googled a bit, and here is the result!

When you set the "theme" attribute in your <page> tag in web.config, in order to apply your Cascading Style Sheets in Visual Studio, you have to set "styleSheetTheme" attribute too. Otherwise, you CSSs won't effect your pages.

 

M

Tags: , ,

Computer | Programming | ASP.net

All about ASP.net 3.5 and VS2008

by MiladKDZ 12. November 2007 23:36

Some features and a really exciting feature!

Tags: , ,

ASP.net | Computer | Programming