OCDProgrammer.com

It's Microsoft's World, and I'm just living in it
View Clarence Klopfstein's profile on LinkedIn

Clarence Klopfstein's Facebook profile

This site is under construction...

Categories

New Comments

Referring Sites


Disclaimer

  • This is MY blog. The views represented here are not in relation to anybody else. Please read my full disclaimer for a more complete disclaimer.

Can you help me with IE 6 Stats?

December 13, 2009 16:45 by ckincincy

I am always looking for a way to justify dropping support for IE 6 as a web developer.  Generally, for small projects, I won’t officially support a browser less than 10% of market share unless the client requires otherwise.  I never waist my time on browsers that are less than 5%.  I just have better things to spend my time on, and I don’t feel bad that Safari decides to render differently than the other major browsers. 

I code to standards and don’t want to go down the rabbit hole of supporting EVERY browser’s unique issues.

Yesterday Michael Wood mentioned that IE 6 was really starting to trail in use.  So I went looking at my stats and was stunned to see how far it had fallen. 

So can you help?  If you would send me your website and browser usage I would appreciate it.  You can comment below, or email me.  If you want your site to remain anonymous, just let me know.

I am looking for the following information:

Top 3 to 5 browser brands (IE, Firefox, Safari, etc..).  Then top browsers by version:

IE 8, IE 7, FireFox, IE 6, etc…  With the percentages.

Thanks!


P3P Header

December 9, 2009 03:00 by ckincincy

 

One thing I learned over the past few months had to do with sharing a website from one site to another via an iFrame.  The problem arises when the domains don’t match.  If your primary site is example.com and the site in the iFrame is exampleinaniframe.com, by default exampleinaniframe.com cannot set cookies or execute certain JavaScript.  Browsers see this as a potential hijacking and throw a security error.

The fix for this is pretty simple, but not simple all at the same time.  There is a header you can add to  your site telling browsers that it should allow it to be put in an iFrame.  Those are called P3P Header’s.  Now the hard part to this is that a search online returns a lot of conflicting answers to what your header should look like.  Then one night, as I was trying to figure out how to do Facebook development, it hit me.  That is how Facebook works.  All of those applications you use in Facebook are really hosted on another site, you just see it seamlessly via an iFrame.  Now since Facebook has 350,000,000 users I figured they probably have this figured out.

A brief search found this very simple and concise P3P header, all you have to do is include this somewhere early in your page load life cycle (global.asax, httpmodule, basepage, etc…):

HttpContext.Current.Response.AddHeader("p3p", "CP=\"CAO PSA OUR\"");

That will tell the user’s browser to not throw a security exception and allow the site to function as needed.


Orchard, Oxite and ASP.NET MVC

December 7, 2009 03:00 by ckincincy

I have been an ASP.NET developer since I joined the team at Cintech in 2006.  I’ve been in the web form world and all the wonders of the PostBack page model since then. 

oxiteThen around the end of 2008 I remember hearing some noise about an ASP.NET MVC project released by Microsoft that got some bad reaction.  Talking about how it wasn’t a good start to MVC.  I never took the time to look deeper as I had other things going on in life, and was happy with my PostBack world.  Turns out this was a project called “Oxite” that is hosted over on CodePlex.

Then July of this year I took a job with a long time friend at Epsilon.  My friend is a Java developer, and through our conversations he kept telling me about this “MVC" way of doing web development.  About how it is so different than how he was being forced to develop on the .NET project we were working on together. 

The more he talked the more I got interested in learning about this new ASP.NET MVC that Microsoft had released.  Around this time CINNUG hosted a firestarter event going over ASP.NET MVC.  I took a Saturday to attend the event and learn some more.

In general I’m eager to learn more and put some of this in action.  This is when I went looking for that project that Microsoft put out.  Upon finding Oxite I see that it was basically a dead project.  The only thing I could find was a post on Erik Porters blog stating this in the comments:

October 08, 2009
Jeff, there is news coming about Oxite, but unfortunately I can't share anything until some other news happens. :( It's looking right now like that news is still a month and a half out. Really sorry! :(

OrchardLogoCodeplexNow this is on top of the fact that Oxite had not moved much since July.  Check ins, yes.  But nothing worth writing home about.  Then in the comments there was some guessing that Oxite was going to become “Orchard”, which was discussed as being a full featured CMS backed by Microsoft, though still being open source. 

Now I had high hopes for Orchard.  Since Oxite had been dead for months, I figured this new Orchard product would be ready to go when released.  I was stoked and waiting for it to be released.  I was all set to move this site to use the Orchard codebase.  When it got officially released I downloaded it, compiled it.. then ran it locally.  Wow, was I ever disappointed.  Orchard is months away from being usable, so here we are in the community with nothing to use.  From what my brief research shows me, at least a year after the release of ASP.NET MVC we have made very little progress in expanding this for people to actually use. 

As harsh as this may sound, I blame Microsoft and I blame the Oxite team. A person named Adam created a discussion on CodePlex stating the following:

October 12, 2009
Guys,

At the moment, I feel that Oxite is hindering developers from creating new ASP.NET MVC blog engines because Oxite is already there, on the other hand, the current official release of Oxite is missing load of features and cannot be compared to other popular engines.

If you are not planning to release soon or you are very busy, just declare this project as no longer supported to open the chance for other developers to start their own engines...

Regards,

Adam

I totally agree.  People don't want to waste their time recreating the wheel when there is a project already out there.  But here we are, over a year has passed and we have very little ‘real’ stuff to show.

Microsoft needs to get its act together.  Many great developers are abandoning the .NET platform for platforms like Ruby, and if you lose developers you lose the market.  Customers don’t care what platform people use, they just want their problems solved.  If those problems are solved and the developer chooses a non-Microsoft technology, then Microsoft loses.

Maybe Orchard is the answer.  Maybe six months from now this blog post looks like the most foolish blog post on the web.  For now, however, I’m still looking for the next big thing.  What comes after .NET for me professionally?  .NET won’t be around forever and being a fairly young man, I have to look toward the future to keep myself professionally relevant. 


Project In Review – Reducing ViewState

November 25, 2009 03:00 by ckincincy

In a .NET world ViewState can get out of hand in a hurry.  In some of our more intense pages the ViewState created by controls could reach well into the 50% range of the page size.  A brief search by a coworker found this solution.

The main thing to take from this article is to insert this snippet of code in your page, or custom base page:

    protected override PageStatePersister PageStatePersister
    {
        get
        {
            return new SessionPageStatePersister(this);
        }
    }

This little beauty of code can reduce the ViewState by 90+%, which is significant.

Now the obvious limitation to this is that your real ViewState is now stored in session, so this will add some overhead to your web application.


Project In Review

November 22, 2009 17:41 by ckincincy

So at work I just finished up a rather large project.  It is live and customers are using it.

What I am going to try and do is recap some of what I’ve done and learned over the past few months so others can learn, and I can easily recall :-)

Some of the post will be rather trivial in nature, so bear with me.


Finding Talent is Hard

October 4, 2009 21:31 by ckincincy

At my current employer, I am the round One interview.  I don’t negotiate or care about salary.  I just talk about .NET.  I have 20 standard questions I ask each and every person, then I throw in a few question specific to their resume. 

Now keep in mind these aren’t hard questions to answer.

What is the difference between session state and viewstate? 

What is the life cycle of an ASP.NET page? 

I don’t go into these interviews looking for a person to know every one of the answers, but there are a few that I consider critical.  I just want to measure their depth and breadth of knowledge of the .NET framework.  What I’ve come to realize is finding talent is hard.  So when I browsed to FoxNews.com and saw this article, I know exactly what they are talking about.  You’d think with unemployment hovering around 10% that talented people would be available.

Then when you do find somebody worth hiring, its not a done deal.  Due to the extremely tight market when you find a developer you want, you are battling with other companies.  Even meeting salary expectations isn’t enough, because of the market the employee can pick and choose which company they want to work for, with little risk of letting a good opportunity pass them by. 

Now just so this post isn’t one big rant I want to throw my thoughts out on a few aspects of this topic.

What does this mean for companies?

1. It means you need to be willing to pay top dollar.  This isn’t a market where you can negotiate down a persons salary.  If they say it is going to take 80K to get them on board, then you need to be prepared to pay 80K.

2. It means you better pay the employees you have.  I’m new to my job, and while money was far from the primary or only factor, it was a factor.  Companies need to pay the employees they don’t want to lose top dollar.  This, surprisingly, isn’t a market where a 5% raise guarantees an employee sticking around.

3. The cost of development has gone up.  The out-sourcing movement has had its affect on the market and there is no India to turn to to drive cost down.  Talented workers are expensive workers.

What can be done about it?

1. Training must be encouraged.  As the previous article stated in another way, you aren’t going to take the factory worker and plug them into these jobs.  People like me have been constantly learning for years to get to where we are.  They need to understand that just because they were a lead worker on their factory line, they will have to be the follower in their new line of work.

2. Government incentives.  I think this is a place where a focused tax benefit could come in handy.  Give companies a significant tax break for hiring entry level workers for these positions.  It cost money to train them and their newbie mistakes cost money.  Give companies a reason to hire relatively new people.

3. College for all.  Yep, the small government Republican just said that.  We need to find a way to get more people into college.  We can’t compete if we don’t have the skills to compete.

What does this mean for the worker?

1. Don’t be afraid to look around.  One of the big causes of the tight job market is that people are afraid to switch jobs.  I’ve never been one to play into this fear much.  I know that with some risk comes reward. 

2. Don’t be afraid to ask for more money.  Lets be real here when I say, they don’t have much of a choice in the matter.

3. Stay up to date on your skills.  This is why there is an allusion of age discrimination in the IT field.  People get comfortable in what they are doing and when technology moves on, they can’t find a job when they need one. 

With all of that being said, my employer is still looking to hire several .NET developers.  If you are interested contact me and let me know.  Going through me, does offer some incentive as I do get a referral bonus.  Not that I’d take it any easier on you in the phone interview, but it sure does make me like you more :-).

[Referenced article in PDF form]


Netflix and Silverlight

January 20, 2009 03:00 by ckincincy

So during some down times I will open up Netflix and watch a movie or documentary that they allow for watching online.

Opened up IE as it never supported Firefox, hit play then got this error:

image

Microsoft DRM software error
Your Microsoft Digital Rights Management software is not working properly and needs to be reset.

What?  I’ve done this how many times?

So I did a search and found this guy having the same error, with no real fix.  So I called up Netflix and was told that I was on the old Windows Media Player, player and that I needed to upgrade to their Silverlight player.  They gave me these steps to follow.

1.       Go to the opt-in page (http://www.netflix.com/silver)
2.       Read hardware requirements and conditions and click the "Get the new player" button
3.       Browse to the Watch Instantly tab, select a movie title, and click the play button
4.       Click Install Now to install the Silverlight plug-in (if you have not already installed)
5.       Congratulations and enjoy your movie!

After doing this, I thought about it… Silverlight can play in Firefox, so why can’t I now watch this in Firefox? Turns out I can!

So if you are on Netflix, make sure you have the latest player by going to the link above.

WindowClipping (3)


I AM A PC

October 19, 2008 19:48 by ckincincy

I've done some odd things in life, but this may be the oddest!  However, I am proud to say, "I AM A PC".

Unless you've been living in a cave you have seen the ads by Microsoft. Many different kinds of people stating how they are a PC, this ad campaign is certainly in retaliation to the Mac vs. PC ad campaign. 

A buddy of mine and I go out to lunch pretty much daily (as he is a co-worker, and fellow programmer).  He was talking about his Halloween costume, dressing up as the PC guy.  And the topic of custom plates came up due to one of the owners of the company we working for recently getting a custom plate of his own.  We determined that when we got back to the office we were going to see if personalized tags were available.  Sure enough we found a few variations of the tag line that we could register.  Since it was his idea I gave him the choice of the primary one "I AM A PC" or a secondary one "IM A PC 2".  He graciously let me have the primary one, and he registered the other.  So here we are with our custom plates!

Here this week we are going to take a photo of both of us side by side and send it into Microsoft's ad campaign.

IAMAPC

IAMAPC_BOTH


Categories: .NET | ASP.NET | Microsoft
Actions: E-mail | Permalink | Comments (8) | Comment RSS

Deprecated functions in .NET

October 10, 2008 03:00 by ckincincy

When I started at my employer I inherited a bit of code that was poor at best.  Over the year I've been working with it, I've been refactoring the code significantly. 

Then we hired another developer and this process sped up a bit and I needed to mark some classes as deprecated.  So over time old code could be replaced with the new code.  I've done this before, but had to do a quick search and as an FYI here is the answer:

[Obsolete("Deprecated: Use GetCustomerID", false)]
public int GetCustomer(int custId)
{
           .... code in here

}

The first parameter is the warning/error message to show in the compiler.  The second option is whether or not to cause an error.  So basically you can say, this is broke don't use it.  Or this is old, use something else.  The first breaks the code, the second allows it to go on for a bit.

HT: Karpach.com


'.', hexadecimal value 0x00, is an invalid character. Line 1, position...

October 5, 2008 16:00 by ckincincy

Last week we upgraded our company from Sybase to SQL Server 2005.  All of a sudden one of our web applications started throwing this error:

'.', hexadecimal value 0x00, is an invalid character. Line 1, position 198128.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character. Line 1, position 198128.

This was happening when I was calling a .NET web service via an ASPX page.  The web service call returned a serialized object:

For understanding, I have a class similar to this:

Model.Customer cust = new Customer();
cust.Id = 1;
cust.Name = "CK IN CINCY";

Now for the code that gave me this error (ie the ASPX code behind):

Model.Customer cust = new Customer();
WebSvc.GetCustomer(1, out cust);

This would blow up.

The web service looked like this:

[WebMethod]
public int GetCustomer(int Id, out Model.Customer cust)
{
     // Fill cust object from database
     return 1;
}

The problem was the data in the database contained null characters.  This is to understood as different than null records.  A null record is self explanitory and can be deal with inside the sql with an isnull call.  The problem was that the record existed but somehow has a null character.  CK IN [NULL CHARACTER] CINCY.  In this case, isnull won't solve the problem.  So after about five hours of searching I found this post.  Which contained this function, which did the trick for me.  Hopefully this saves you 5 hours of your time :-).

 

/// <summary>
/// Removes control characters and other non-UTF-8 characters
/// </summary>
/// <param name="inString">The string to process</param>
/// <returns>A string with no control characters or entities above 0x00FD</returns>
public static string RemoveTroublesomeCharacters(string inString)
{
    if (inString == null) return null;

    StringBuilder newString = new StringBuilder();
    char ch;

    for (int i = 0; i < inString.Length; i++)
    {

        ch = inString[i];
        // remove any characters outside the valid UTF-8 range as well as all control characters
        // except tabs and new lines
        if ((ch < 0x00FD && ch > 0x001F) || ch == '\t' || ch == '\n' || ch == '\r')
        {
            newString.Append(ch);
        }
    }
    return newString.ToString();

}