Thursday, March 29, 2007

ASP.Net Membership: IsLockedOut property

Hello bloggers!

Today we looked up some info about the ' IsLockedOut ' property of the ASP.Net Membership Control. If a user enters a wrong password more than three times in a row, IsLockedOut will be true. The problem is that a user can't login anymore until an administrator unlock his account.

Password crackers can brute force user accounts. So it can happen you can't login because someone else tried to crack your account with several invalid passwords. To solve this problem, we can just raise the number of maximum invalid attempts.


Well, for those who agree with our statement here are 2 ways to disable it.

Simple Way (and still effective):
Just add the maxInvalidPasswordAttempts property to your web.config file:
example:


Remember, the counter resets when a successful attempt is logged.



Advanced Way (it auto-unlocks your account if you reached the maximum invalid attempts):
Click Here to go to the CodeGuru Tutorial


Changing CSS Styles at runtime
Oh yeah, another quick tip, if you change the css style of a webpage in Visual Studio, you need to Clear your cache before reloading the page. You can do this using CTRL-F5 instead of the normal refresh (F5)

Friday, March 23, 2007

MSSQL Handling NULL Values

One of the most horrific problems in database-access are fields which allow Null-values, I remember all the IF statements it took in COBOL to handle this problem (with a CSV file) and I was afraid I had to go through the same hell as back then. By making use of the ISNULL method we were able to remove the evil at it's root, the database...

An example :

SELECT username, ISNULL(email,"") FROM tblUser

This query will set the emailadres to an empty string instead of a null value if no value is entered.
Since the abilities to handle Null values with Typed Datasets are rather limited, this was a fine solution..

Thursday, March 22, 2007

Visual Studio makes your properties!

This is something I already know for a while but it's a very handy features which the Visual Studio developers have made quite hard to find. When your declaring your business logic / domain classes, this feature will surely be handy. When you want to encapsulate a private/protected field (the good OO way...), you'll probably make accessors for it. Writing all of these getters & setters is a lot of work if you've got around 10 attributes you want to cover.

Here's the trick, just right click the field you want to encapsulate


And Visual Studio will create the property methods:

Everybody who has coded with Visual Studio before is probably aware of this tip but for new coders, this is a real timesaver!

The other refactoring options are also extremely handy for code optimization. The Extract Method options is also one of the features I use quite frequent...


Wednesday, March 21, 2007

Using XML Serialization

While finishing our Interactive Course project, we decided we had to do something about the rather oldschool way we parsed our XML files. The code to parse an XML file was divided into two classes, a parser and a schema validator, totalling for some 150 lines of code. Luckily Kurt (who is guiding our internship) let us in on the whole XmlSerialization thingie...



Click for a larger view...

Using the xsd.exe program, which can be easily found in the Visual Studio directory, we made an XSD scheme for our xml file. After the XSD was created by the program, we fed the program the XSD and a serializable class is created for our XML file. After we had imported this class file into our solution, the code to load the course from an XML file looked like this:

XmlSerializer xs = new XmlSerializer(typeof(Course)); FileStream fstrm = new FileInfo(fileName).OpenRead(); return (Course)xs.Deserialize(fstrm);

These 3 lines replace the 150+ lines we coded to parse and validate the XML file, if only we would have known ;-) Luckily, now you do! So don't go using the good old (even deprecated) XmlReader class, serialization is the next best thing!

Monday, March 19, 2007

ASP.NET Roles & Membership

We spent the morning trying to figure out how we could migrate the ASP.NET membership database (which is a SQLExpress DB) to SQL Server 2005. This great article gave us more than enough info to do this, although we ran into some problems along the way. Nevertheless we got things up and running again...

Friday, March 16, 2007

Interactive Course player!

Good news today, we've finished developing a small additional project. It's an ASP.NET Ajax powered website that will enable the competence leaders to post online video courses on the net for the consultants, here's a list of features:

- Completely XML customizable
- Customizable themes
- Animated Text while the video is playing (like subtitles...)
- Nice & simple Ajax GUI!



I have to say I'm pretty exicted about the result, I like it alot :D

I have to say we've had a bit of trouble updating the playtime of the video with the text, the final solution is a mixture of iframe,ajax,javascript and a good old Session variable. The text also fades out and in when it changes, cool :) For anyone who's interested, we based our mediaplayer code on this article, we had to recompile the DLL and make some code modifications first to optimize things. There was also an error in the code so that the height of the videoplayer wasn't set, luckily we managed to fix this to!

ASP.NET Panel Control problem

Took us just a few Google lookups, but we've had some problems with the Panel control in the standard ASP.NET toolbox. The panels were drawn over the other content of our site. The solution: simply remove the height attribute of the panel... Guess solutions don't have to be that hard al of the time...

Some technical info on our project

The project will be built using a service-oriented architecture. The methods we'll be using are:

- ASP.NET
- C#
- The new MS Ajax 1.0 framework (+the control toolkit)
- SQL Server 2005
- The EntLib library (for logging purposes)

Througout this blog we'll be posting some of the things we've learned...

Some info on our project...

Our internship project is all about knowledge management. We were assigned to build a knowledge management application which will track individual knowledge for all of Ordina's consultants. Another purpose of this application is to supply resources (webcast, trainings, books) to the employees. No question about it, an application like this could be a great asset for a consulting company like Ordina, so we'll give it all we've got ;-)

Introduction

We are 2 Belgian students in informatics at Hogeschool Gent, currently we are working on our internship with Ordina, an IT-consulting company. Purpose of this blog is to summarize some of the things we've learned during the internship and to keep people posted about the stuff we are doing. Hope you like it...

Jonas Van de Biest
Dierickx Dominique