Tuesday, January 12, 2010

Asp.Net Intrinsic properties

By default the System.Web.UI.Page exposes Session, Request, and Response properties.  However often you may want to access these properties outside of the Page context. The easiest way to do it is to use HttpContext.Current static property to obtain the current request’s HttpContext.  Thus, you can obtain a session variable like this:

HttpContext.Current.Session[“userid”].


Vote for two important CodePlex features

Eric Hexter, from MvcContrib project, has just asked the community to go and vote for a few issues with CodePlex. Here is his blog for reference, http://www.lostechies.com/blogs/hex/archive/2010/01/11/a-call-for-help-vote-for-my-codeplex-issues.aspx. Go Vote!

Monday, November 16, 2009

Windows Management Framework was released!

I always like playing with management tools for windows since dos days.  I think the release of Windows Management Framework at the end of October is truly the next step in Microsoft console/command-line tooling revolution.  Thank you, Jeffrey Snover.

Thursday, October 29, 2009

Web Goat – Interesting way to learn security on the Web.

As I deal more and more with web in my daily life, I realized that web security is a very intricate subject and tough to learn as well. The next iteration of CodeCamp is in town in a week, so I will have a chance to check out Web Goat. Due to time constraints, I wont be able to research beforehand, so it’s exciting to learn about something completely new.

Monday, May 25, 2009

Viewing temp table structure

For some reason I can never remember to properly retrieve connection specific temporary table’s structure, i.e. #tempCustomers. Due to the fact that the table resides in tempdb, this is the format required:

use tempdb
exec sp_help #tempCustomers
Highlight these two lines in Management studio and press F5!

Friday, May 8, 2009

Virtual Function Calls from Constructors/Finalizers … Bad Idea!

So I am skimming over this book, Framework Design Guidelines by Krzysztof Cwalina and Brad Abrams, when authors note to “avoid calling virtual members on an object inside its constructor”. At first a developer might not think about the danger but it does make sense with a quick example that authors provide.

Here is another one i cooked up:

public class Trans {
public abstract Log();
public Trans() {
Log(...);
}
}

public class SomeTrans:Trans {
private Logger logger;
public SomeTrans() {
logger = new Logger();
}
public override Log(...) {
if (logger == null)
Console.Write("Oops!");
else
logger.write(...);
}
}

Using the base class to execute common code that all derived classes will might seem like a good idea but here the Trans constructor calls the derived type’s Log method before SomeTrans constructor is called. Compiler is unable to detect this danger because binding happens at run-time so be very aware.

The rule of thumb is to never do that!

Also note, C++ behaves differently as it does not allow a virtual traversal because at base construction time the object type is Trans.

Wednesday, April 1, 2009

Managing IIS7 SSL settings without SSL binding

    I was messing around with IIS7 site settings and ran into the error when I tried to disable SSL requirement for access.

InvalidSSLSettings

It appears IIS does not allow you SSL settings modifications if  HTTPS binding was already removed.

Make sure you have Binding like this:

IIS7_https_binding