Archive for the 'ASP.Net' Category

When developers make me cry…

Posted by toby mills on Apr 06 2009 | Rant, Web Development, ASP.Net, Technical developement, Personal

From time to time I use web sites which frustrate and anger me. I’m left wondering why they are hard to use, why so little thought has been put in and why some obvious opportunities have been missed. But what really really makes my blood boil is when I see a site that has been badly developed, especially when a developer has taken a reasonable, sometimes simple concept and made a complete mess of it.

Today I have, amongst other things, been looking over a clients site, Sorouh. The website is far from the worst i’ve seen in this region, in fact it looks positively up-to-date compared to some i have seen. The design is simple with a good amount of information and even has a site map for SEO purposes but then i started to notice strange things. The site map link was not being recognized as a link, on hovering over the “Developments” menu the link shown was different from the page you landed on. Then i looked at the source code and i nearly cried.

The developments home page is nearly 800Kb in size, the homepage html alone is over 1700 lines and 155kb in size and the javascript is 700 lines long and 214kb in size! All the page displays is a bit of flash, a few images and some 400 words! Who ever developed the site seems to have included every Ajax / Javascript library. The have surrounded simple links with entire html tables which then have onClick events on them which over-rides the link its surrounding. Every menu link is re-written in javascript and the links that appear in the html are different to the ones that appear in the javascript.

I fail to understand how someone can code such a simple site so badly. Time is not even an excuse as they have way over complicated it and at least doubled if not trippled the amount of work they needed to do. Programming should be simple, elegant and serve a purpose, not a complete waste of time and space! What makes this worse is it’s so un-necessary, adversely affects SEO and impacts the time taken to display the page and thus the user experience.

no comments for now

Excellent new Website Administration Tool and Custom Membership Provider

Posted by toby mills on Nov 19 2008 | Web Development, C#.Net, ASP.Net, Technology, Technical developement

As I’ve previously written i’ve been spending some time recently catching up on with the .Net community and exploring some of the new tools that are out their to assist and speed up development of ASP.Net projects. One of the tools I have come across and been playing with is a new ASP.Net web site administration starter kit created by hunzonian which uses the ASP.NET Membership Provider. The starter kit is basically a template to produce an admin front end website for the ASP.NET Membership Provider. It looks good and works well however i have found the following issues:

  • Although i have yet to fully develop using MVC, it would be nice to see this implemented using the framework. The main reason for is would be the clear delimitation between functionality and presentation.
  • One of my main gripes with the ASP.NET Membership Provider is the way it stores profile data as one long CSV string in a single field. This means to run any queries against it you have to extract the data from the field and manipulate it to seperate the values and then run your query against it. I much prefer having each profile setting in a seperate database field and there are providers out there that will do this.
  • Currently to add new profile fields to the schema you have to edit the web.config and then add the fields manually to the forms. Not a lot of work but would be nice if the admin site had a way to do this.
  • The site currently uses CAPTCHA for logging in and another number of area’s. While this is a useful tool I would life some way to easily turn it on and off.

Overall this is a very good starter kit and certainly looks better than anything i could have put together on my own. It’s also worthwhile bearing in mind that the full source code is there so you can easily amend functionality.

Enjoy and let me know what you think…

no comments for now

EF’in Hell! LINQ isn’t dead, just paralysed….

Posted by toby mills on Nov 19 2008 | Web Development, C#.Net, ASP.Net, Technology, Technical developement

Well it seems there has been some confusion in the community about the future of LINQ to SQL and Microsoft has tried to clarify their position and reassure developers & companies alike in a recent posting. The first item to be clarified is that LINQ (Language Integrated Query) will continue but LINQ to SQL development may stall.

So what’s the difference? LINQ is a language which allows developers to easily construct statements (like SQL) to be exectuted against a data source. Its a great language which allows developers to quickly and easily construct powerful queries without tons of code. To use LINQ against a data source an interface has to be provided, e.g. to execute LINQ against a dataset, XML data or SQL. This is where the problems arise, MS have produced an interface for LINQ to connect to SQL (LINQ to SQL :-)). MS are also working on another data interface called EF in which it seems they are putting all their Eggs. As i said before i can understand their want to concentrate development but many people are asking why can the two technologies not co-exist? Especially those that have tried both and found difficulties, e.g. Chad.

So, what is the situation? Well MS is saying that LINQ is definatley not going away which is great. However they are probably going to stop developing LINQ to SQL at some point in the future however they will continue to do some development based on “Customer Feedback”, whatever that means and whoever that is. MS say they are just trying to be open about future paths they are going to take which is appreciated. However most people, including myself, who use LINQ would like to see support for LINQ to SQL continuing. So we’ll just have to watch this space to see what happens…

no comments for now

MS PDC 2008 - A room with a view

Posted by toby mills on Nov 17 2008 | Web Development, C#.Net, ASP.Net, Technical developement

At the end of October, Microsoft held it’s Professional Developers Conference (PDC) which hosted presentations on current and future technologies being developed by Microsoft. These ranged from the unveiling of Microsoft’s cloud computing initiative, demo’s of the new Windows 7 and naturally talks on developing for all of Microsoft’s technologies. Its a great event and one i would love to attend however it’s held in the USA and time & cost has always prevented me from attending. However this year all of the presentations have been made available online for all to watch and you can even download them!

This of course has meant that i’ve been able to ‘attend’ all the presentations that i would have otherwise missed and viewed some presentations that i probably would not have gone to see even if i had been there all from the comfort of my home. Some of the presentations i have watched have been superb and ‘must’ see’s for developers so  i thought i would round up my favorite ones and list them here. You can view all the talks at Channel9.msdn.com

ASP.NET MVC: A New Framework for Building Web Applications

This is a great talk by Phil Haack on the new MVC framework. He is also joined by Jeff Atwood from Coding Horror & Stack Overflow where he talks about his experiences in using MVC to create Stack Overflow. This is a must see for ASP.Net web developers.

Coding4Fun: Windows Presentation Foundation Animation, YouTube, iTunes, Twitter, and Nintendo’s Wiimote

Not all development has to be for work! This is a great talk given by several developers who have produced some simple applications using .Net to interact with a variety of web applications and more. Its worth the time to watch if only to see the Wii Remote integration with MS Maps.M

Microsoft Advertising Platform: A Day in the Life of a Click

This is a great talk not just for developers but for anyone who is interested in knowing how online advertising works. The talk goes through the differences between Pay-Per-Click, Banner Advertising and much more. It then delves behind the scenes to see how Microsofts AdCenter works in recording clicks, delivering adverts and billings. Although its Microsoft AdCenter focused the content of the inital quarter of the talk can easily be applied to many other online advertising areas including Google.

There are many more talks then i have outlined here and i for one will be viewing quite a few more and posting updates here.

no comments for now

EF’in Hell! LINQ is Dead

Posted by toby mills on Nov 11 2008 | Rant, Web Development, ASP.Net, Technology, Technical developement

Recently I have taken some time out of work to sell and move out of my house and prepare to move to Dubai. I also wanted to use this time to read up on the latest .Net techniques, frameworks as well as explore a few other development platforms. I’ve thoroughly enjoyed this time and it has made me realise how important it is for developers, no matter in what position, to keep abreast of the latest developments within their communities.

Anyway, over the last month or so I have been playing with a number of new .Net packages (MVC, ASP.NET WSAT, Linq to SQL to name a few), using VS 2008, reading up on the advances in the .Net 3.5 framework and getting back in touch with the community. I’ve really enjoyed getting back into the thick of it and have been pleasantly surprised at how far .Net & ASP.Net have come in assisting developers to rapidly role out and maintain applications. I was even starting to feel quite smug with myself at learning new techniques and ‘tooling up’ for work. So imagine my surprise and frustration when it’s announced that Linq to SQL is being dropped by Microsoft in favour of ADO.Net EF!

Now I can appreciate that Microsoft wants to concentrate their development on ADO.Net EF rather than have two separate similar frameworks for data access and manipulation however Linq to SQL was/is a great fast & simple way to access data sources without all the hassle of data sets and Stored Procedures. Having only played with both for a short period of time and not having used either on professional projects I’m not able to fully argue the pros & cons of either framework however what I can say is that by dropping Linq to SQL, Microsoft is in danger of losing the trust of the community and preventing development at the cutting edge.

Think of all the projects which have used SQL to Linq which are now redundant, all the time people have spent creating documentation and assisting other developers in learning the new techniques which has now been a waste of their time. Why should they continue to support emerging technologies for them only to be pulled, who’s employers are going to continue to let their developers experiments with the latest Microsoft techniques if they fear they will not be supported going further? A great example is the new stackoverflow.com website which has been developed using some the latest cutting edge .Net techniques including MVC & Linq to SQL. To ensure easy maintenance going forward they will now have to consider re-writing their DAL using alternative technologies otherwise future developers working on the site will have no idea how it works.

The one saving grace may be that Linq to SQL was released to the community so perhaps some people will take up the baton and drive it forward. While Microsoft is making some great moves to work with the community by releasing code on CodePlex as well as the being more open about development but all this risk’s being in vain if the community turns its back.

Suppose I better get on with learning ADO.Net EF and pray it doesn’t get pulled too.

1 comment for now

Impersonation in .Net

Posted by toby mills on Oct 22 2008 | ASP.Net, Technical developement

I’ve been struggling to get a project another developer has been working on to build on my machine, the main problem has been that the files within the App_Code folder did not recognise any of the dll’s or their class names and so other than the basic System and Microsoft namespaces I could not access anything. After quite a bit of frustration I have finally tracked down the issue…

The project uses windows impersonation to enable access to certain features within a CMS system this has been set in the web.config. It was set to use another user account and for the purposes of publishing the site I did not see any reason to change it. Oh what a fool I am. It seems that Visual studio actually uses these credentials to access files on the system and as the impersonated user has never logged onto my laptop (or perhaps his password has changed) VS would not allow the App_Code folder files to access the dll’s. Changing the impersonation settings to my own resolved this issue. So the conclusion is if you are using impersonation ensure the account is valid on the machine you are developing on and not just the one you run it on.

Alternatively to avoid this problem altogether DON’T user impersonation or use a generic network / domain account which is documented and shared with all other developers. The main reason for this is that if you use a personal account then it could be easily hijacked and series damaged could be caused because of your user privileges not to mention that your password will be visible in the web.config!

no comments for now

Yahoo’s Best practices for speeding up your web site

Posted by toby mills on Oct 22 2008 | Web Development, ASP.Net, Technical developement

A while back i came across this great website and subsequent tool for improving performance of a website and ever since have been meaning to blog about it.

The page has been created by Yahoo as a list of best practices when producing websites. Some of the items are only applicable to large websites, for example placing images on a separate domain, however by in large we can learn from them all. Although most of the items are obvious like reducing HTML/CSS/JS file sizes, some of the items where extremely interesting. For example one of the entries states:

 “When the browser makes a request for a static image and sends cookies together with the request, the server doesn’t have any use for those cookies. So they only create network traffic for no good reason. You should make sure static components are requested with cookie-free requests. Create a subdomain and host all your static components there.”

It had never crossed my mind before that cookie requests would initiate a cookie request and the loads that would go with that request. Needless to say the article is a must read for any web developer.

The same article also mentions CSS & Javascript Minimisers which reduce the file size of CSS & JS by removing unnecessary characters and line breaks. It turns out that Yahoo! has created an excellent tool, the YUI Compressor,  which does just that. This command prompt based program will remove all the unnecessary spaces, line breaks and more from your code and I’ve seen it take nearly a third off a file size. You can even integrate it with your IDE and have it run when you publish your files. For visual studio see these google results.

Enjoy

1 comment for now

New developer’s resource

Posted by toby mills on Sep 16 2008 | C#.Net, ASP.Net, Technical developement

A wonderful new resource has been created by the enterprising Joel Spolsky and Jeff Atwood. I have long been a fan of Jeff’s Coding Horror blog and when i heard that he intended to try to create a new on-line resource for developers i was intrigued if not a little sceptical but thought i would follow its progress via their pod cast. Well, yesterday (15 sept 08) the site was finally launched and i have to say its looking good. It’s still in the usual “beta” format but it’s working well and I’ve already taken the opportunity to add a few responses.

As always with projects like this only time will tell how successfully this venture will be but i certainly wish all the best and will be using it a lot myself to assist and be assisted by the vast community out there.

no comments for now

Testing load balanced servers

Posted by toby mills on Sep 16 2008 | ASP.Net, Technical developement, Personal

A developer has asked me about testing individual sites configured for load balancing to ensure each is working properly. I have found the best way to do this is to set-up a new DNS record (or external IP) for a site and point it to the server you want to test.

Generally when using load balanced sites across two servers I tend to create three records for the sites:

For example:

  • Test.site.com = loadbalancer.site.com
  • Ws1.Test.site.com = ws1.site.com
  • Ws2.Test.site.com = ws2.site.com

You will also need to add the individual urls to the appropriate website properties in IIS (or similar)

Also, i configure all servers to add the server name to the http response headers which you can view using firefox’s web developer tool bar. This lets you see which server is rendering the page without giving away any secure information and is hidden from the users view.

An example of such an HTTP header for a server named WS2 would be:

Date: Tue, 17 Jun 2008 14:18:23 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Webserver: ws2
Content-Length: 5558
Content-Type: text/html
Cache-Control: private

200 OK

no comments for now

Load balanced servers & viewstate

Posted by toby mills on Sep 16 2008 | ASP.Net, Technical developement

Recently an issue arose with a clients web site which has been caused by the fact that the site is load balanced and uses view states. When deploying load balanced web sites which use view states you must ensure that they specify a machineKey in site’s web.config, this key is used to encrypt and de-crypt the values passed. However, these are normally set at a server level and different on each machine. This means that when a user navigates from one page to another, and in the process is transferred to a different server (because the load balancer sent them to a different server), then asp.net can not read the encrypted viewstate as uses a unique key and will fire off an error.

You can read more about this @ How To: Configure MachineKey in ASP.NET 2.0

T

no comments for now