Famous .Net websites found on the web (Part 2)

by Damiaan Peeters 1. September 2009 10:30

Ok, I admit.  I know my blogging rhythm is very low this year, it's about the opposite of my 'normal' day-to-day life rhythm. But I prepared in the past months this blog post…

From time to time I stumble upon famous web sites using .Net (part 1).  I would like to add some sites to the list.

Let me know if know any other big web sites using .Net technology, so I can complete the list.

TeamViewer – Desktop Sharing over the internet
image
Intel Download Center
image
Hardrock Café’s Memorablia  using Silverlight technology, Deepzoom.
image

Have you ever tried zooming really deep?  Look at this post: How to really show of with deepzoom

CRDC.Be - Official Belgium Database for Number Portability
image

Stanford Engineering – Sub site of university

image

Rabobank.be – online bank (and know sponsor of cycling)
image
DoubleClick – online advertising
image
International Telecommunication Union
image

Tags:

.Net

How to really show off Deepzoom technology

by Damiaan Peeters 31. August 2009 11:57

What is Deepzoom

Deepzoom is a product build on Silverlight technology.  It gives you the ability to smoothly zoom and pan on images.  The loading time is incredibly short because only parts of images are send over the network. This type of browsing can be compared with viewing imagery on google maps, live earth.

A nice example is the Memorablia of the HardRock café.  I searched for a guide on the internet, on how to get as deep as possible on the pictures.  This examples goes even a few levels deep.

If you search on the web for Deepzoom, you will find much more details and explanation.

Where to start

Go to http://memorabilia.hardrock.com/

and look for “Paul McCartney – The Beatles Letter from Paul and Beatles autographs”.  (Item number: 043311).

Finding this item, can be easily done by:

  • be clicking on “The Beatles” on the left side, or
  • use the search on the top right of the screen like this:
    image   or image

The item you are looking for is this one: 
 image

Go deeper

Have you already noticed the stamp on the left top of the envelop?  That is where you should go.  Use your mouse scroll wheel to enlarge this item.

As you will see this is not a normal stamp.  These are pictures of various buildings.  (Does anyone know which buildings these are?)

image

Zoom into the picture of the 3th row, 2nd column.  If I’am not mistaken, this is the Seattle hardrock Café.

image

If you thought this is cool, go to left below the middle of the image, you will see some white suites

image

image

Then zoom in on “The Beatles” Doll's image in the middle.

image

This last doll’s are available as a separate item  in Memorablilia: The Beatles “Bobb’n Head” dolls, and is available under Item number 051228.  The cool thing is, this contains some embedded video as shown below (click More Info – Video).

Do it yourself

You can make yourself Deepzoom content by using deepzoom composer.  Try it out, and let me know if you archived something spectacular.

UrlEncode without HttpContext

by Damiaan Peeters 25. August 2009 12:19

Yesterday I had to use the UrlEncode function.  UrlEncoding is used to converts all illegal characters in a URL to valid characters.  For example the space will be converted to %20.

Fortunately the .Net Framework supplies a UrlEncode method on its Server Class.  The server class resides in the HttpContext.  The problem is that you need a HttpContext Instance to call this class.

Using Reflector, I found out that the UrlEncode method on the Server Property uses the HttpUtility class.

image

So, instead of using this: HttpContext.Current.Server.UrlEncode(text)
you can also use: HttpUtility.UrlEncode(text)

The only thing to use this is to include the System.Web assembly in your project.

Managed Extensibility Framework Introduced By Bart

by Damiaan Peeters 19. August 2009 17:54

I have been thinking several years about how to implement Extensibility in a decent manner for one of my applications.  The problem is that as a sole freelance developer, implementing extensibility is not something you NEED.  It is more a ‘nice to have’.  At the end of 2008, I found the MEF (Managed Extensibility Framework).  But due to a lack of time and lack of articles about it, never started investigating into it.  I admit, I do not always jump on the newest beta technologies right away.

Unfortunately, when you search for some information on the MEF CodePlex website on how it exactly works, it doesn’t really encourage you to read further…  Try to dive in the first to links on the topic “Where to go next”

  • First there is:  Learn more about MEF .  Completely correct, but a 100% cryptic message for dummies.  Telling someone you have to start with a container or a catalog without explaining what a catalog or container is, is not very convincing.
  • Or take the programming guide, just a few steps to do very complex things.  My problem was not “how to”, but I wanted to understand what I was doing.  Adding references adding class or method attributes can be done by my little sister, but would she know what she has done?  I Guess not, I even bet she doesn’t understand these terms.

So, I watch out for months about articles covering the Managed Extensibility Framework (MEF).  Articles explaining the basics. Telling me what it exactly is, or what the basics are.  Some sort of “Hello World” for advanced programmers, but “MEF dummies”.

Earlier this week I found the article an article, written by a Belgian fellow, now working in Microsoft Redmond.
His blog posts tend to be very technical material for advanced LINQ adepts or Expression Tree lovers. This time he covered “MEF for Dummies”, just what I needed.  I’ve written before about the mouse-hating code-lover called Bart De Smet. (See a previous post “Bart De Smet gone mad about extension methods”.) 

Bart proved his excellent writing capabilities in his blog post written earlier this month. If you are interested in MEF, then read  A Whirlwind Tour through the Managed Extensibility Framework.  I highly recommend it.

Congratulations Bart, it was easy to read, even humorous. And most of all it was very understandable.  Thank you very much!

Tags: ,

.Net

Bing indexing obsolete page of Post.Be

by Damiaan Peeters 11. August 2009 12:27

De national Post service of Belgium, has changed it’s site and Bing managed to indexed the obsolete page…  Look at the URL: www.post.be/site/nl/obsolete.html.  I was curious and tried to find out why Bing gave me the wrong result.

bing search depost.be

Ok, i admit.  It was not the best search i have done.  Searching for post, would give the good result. 

Anyway, this is a screenshot of the web page:

"page unavailable" Post.be

See the text at the top?  It’s Dutch and French.  Translated into English it says: “This page is not available anymore, click a link below to visit our new site”.   I didn’t got it.  If the page does not exists anymore, was Bing wrong indexing it? 
No!  Bing got it right (sort of).  It was in fact the webmaster of Post.be who forgot something.

Explanation

The page you are entering is for a normal visitor a standard NOT FOUND page.  When visiting a page which doesn’t exists, the server should give a 404 status in its response.  The HTML can be customized like the screenshot above for an improved user experience.  But crawlers & indexers need the correct status.  In this case a 404 error.

When you investigate all requests send to the web server, every requests gets a 200 Status code: “Successful”.  I used Fiddler to verify the page request:

fiddler result of the URL

As anyone can find on the web, it tells the visitor that the request was successful.  Not a single 404 status code can be found in the second column.

A user centric solution

For a better user experience, it would have been nice of “De Post” to redirect me automatically to the new homepage.  The page I was visiting here was obviously an obsolete page.  This can be done in HTML using a Meta Refresh Tag.  Looking at the HTML source, no redirect is made.

HTML source of the web page

It would have been more user friendly, but not the best solution.

What about 301

A 404 would have been a good start.  Bing, Google and other search engines would not mention the result in their SERPs for long. I guess de webmaster of “De Post” must have had some reason not to use a 301.  A 301 is a status code telling the visitor (human or not) that the page has moved permanently to a new place.  Together with this status code the new URL is supplied.

What exactly happens when a 301 is send from the web server back to the visitor?

A human visitor

The browser (Internet Explorer, Firefox, …) of the visitor will notice the 301 status code and load the new page supplied with the 301 status code.  The end user might notice a new page is loaded because the shown URL in the browser will be updated.

A Bot / Spider

A spider or a bot will notice the 301 also, and will remove the old URL from their index and update it with the new URL.  Using a 301 has major advantages when migrating to a new site because you can retain all page rank from any incoming links.

ConvertAll using lamba

by Damiaan Peeters 4. July 2009 17:41

When we are using generic lists, we always used a delegate when converting a List<int> to a List<string>.  This is very easy using the know ConvertAll method.
Normally, we should call it like this:

List<int> l1 = new List<int>(new int[] { 1,2,3 } );
List<string> l2 = l1.ConvertAll<int>(delegate(string s) { return Convert.ToInt32(s); });

Now that we are using .Net3.5 we can use also lambas, so your code changed now to this:

l2= l1.ConvertAll(s => return Convert.ToInt32(s) );

Pretty readable imho…

Tags: , ,

C#

EXECUTE permission denied on object 'aspnet_CheckSchemaVersion', database 'myDB', schema 'dbo'.

by Damiaan Peeters 7. April 2009 18:27

Problem

Today I launched the aspnet_regsql.exe.  Unfortunately I received the following error:

EXECUTE permission denied on object 'aspnet_CheckSchemaVersion', database 'myDB', schema 'dbo'.

Solution

Take the properties of the “NT Autority\Network Service” user.  Select the myDB database and add all the necessary Roles like aspnet_Membership_FullAccess to the user. 

image

In the screenshot are all the databaseroles added.

Tags: ,

Asp.Net | SQL

Update Query versus Updatable cursor

by Damiaan Peeters 28. February 2009 02:02

Tonight someone gave me passed me an awfull SQL Query.  After a small few adaptions some the tablescans where eliminated.  I still believed it would be quicker using a cursor.  So, i started to create a SQL script with a cursor.

Create and populate test data

This was the Table to work against:

CREATE TABLE temptbl   
(    
  ProductId INT primary key identity(1,1),   
  Period INT,   
  Qty INT,   
  BFQty INT,   
  CFQty INT  
)   

 

To populate the table, you can write a million of bytes or create a small loop

-- Populate the table with some data
INSERT INTO temptbl VALUES(200801,1,0,0)   
INSERT INTO temptbl VALUES(200802,2,0,0)   
INSERT INTO temptbl VALUES(200803,3,0,0)   

DECLARE @RowCount INT, @Random INT, @Upper INT, @Lower INT, @periode INT

SET @Lower = 0
SET @Upper = 12
SET @RowCount = 0

WHILE @RowCount < 10000
BEGIN
    SET @RowString = CAST(@RowCount AS VARCHAR(10))
    SELECT @Random = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
    INSERT INTO temptbl VALUES(200801+@random,@random,0,0)   
    SET @RowCount = @RowCount + 1
END
Select count(*) from temptbl

 

The solution with one single query

This was the – not sooo awful solution to fill the brought forward and carry forward fields

DECLARE @Value INT
UPDATE temptbl SET  
     @Value = (SELECT ISNULL(SUM(Qty),0) FROM temptbl AS InnerT WHERE InnerT.ProductId=temptbl.ProductId AND InnerT.Period<temptbl.Period),
     BFQty = @Value,CFQty = @Value + Qty   

Solution with (updatable) SQL cursor

The trick to let it run fast, is – if i understood it well – using the updateble cursor.  Normally you should avoid using this type of cursor.  But now we need to run through the whole table anyway and update each field using the data of the previous record.  I highlighted the 2 important parts.

begin transaction
DECLARE MY_CURSOR Cursor DYNAMIC
FOR SELECT ProductId, qty FROM temptbl order by productId, period
FOR UPDATE  OF BFQty, CFQty

Open My_Cursor
DECLARE @Value int, @Qty int, @prodId int, @OldProdId int

Fetch NEXT FROM MY_Cursor INTO @ProdId, @Qty
SET @OldProdId = @ProdId
SET @Value = 0
While (@@FETCH_STATUS = 0)
BEGIN

    SET @OldProdId = @ProdId

   UPDATE temptbl
    set BFQty = @Value, CFQty = @Value + @Qty
    WHERE  CURRENT OF My_Cursor

    SET @Value = @Value + @Qty

    Fetch NEXT FROM MY_Cursor INTO @ProdId, @Qty
    IF @OldProdId <> @ProdId
    BEGIN
        set @VALUE =0
    END
END
CLOSE MY_CURSOR
DEALLOCATE MY_CURSOR
commit transaction

Conclusion

Without the transaction it took 2 seconds for the cursor solution, and less than 1 second for the sql statement.  Adding The transaction dropped the cursor solution also below a second.

BUT, it took me 1 hour and a half to create (and learn about updateble) cursor solutions.  It’s 2:04 am, the other guy is in bed next to his girlfriend for some very reasonable time.  And I even haven’t fully tested if the cursor solution has the correct return (i even doubt it).

 

Normal

In transaction

Human work time

Total

Statement

< 1 sec

n.a.

10 minutes

winner

Cursor

2 seconds

< 1 sec

1,5 hour

loser

Next time, i might write a sql query right away.  The optimizer of MSSQL does it’s work anyway.

Hotsync not working on Palm (Tungsten E) when using InfraRed

by Damiaan Peeters 2. January 2009 12:27

Today I had an old "Palm Tungsten E" in my hands.  The user had a problem synchronizing it with Hotsync on the computer.  It always worked until I the day cleaned the computer from some junk a week ago. The synchronization worked flawless when using the cable, but didn't occurred when using Infra Red (IR).

The Error

Hotsync problem

Unable to initiate hotsync operation because the port is in use by another application.

The Solution

Just reboot the Palm.
(And select IR when opening hotsync on the Palm.)

Tags:

General

ASP.Net Membership API Cannot resolve collation conflict for equal to operation

by Damiaan Peeters 31. December 2008 09:36

Error

I was using the ASP.NET SQL Server Setup Wizard (aspnet_regsql.exe) to deploy te database to the production SQL Server 2005.

image

Creation or change of the SQL Server database failed.

Setup failed.

Exception:
An error occurred during the execution of the SQL file 'InstallRoles.sql'. The SQL error number is 468 and the SqlException message is: Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
[cut]

SQL file loaded:
InstallRoles.sql

Commands failed:

[cut] …  the failed SQL code

SQL Exception:
System.Data.SqlClient.SqlException: Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
[cut
]…
Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Web.Management.SqlServices.ExecuteFile(String file, String server, String database, String dbFileName, SqlConnection connection, Boolean sessionState, Boolean isInstall, SessionStateType sessionStatetype)

Cause

Apparently this error happend when creating the asp.net membership stored procedures: aspnet_UsersInRoles_AddUsersToRoles or aspnet_UsersInRoles_RemoveUsersFromRoles.

The reason is pretty straithforward.

The aspnet_Roles table uses collation “latin1_General_CI_AS”.

image

While my database has a SQL_Latin1_General_CP1_CI_AS collation by default (just like my SQL server collation).

image

Solution

Use the SQL Profiler to get the Code of the of the Stored procedure which need to be created.  The SQL scripts of the ASP.Net Membership can also be found under: C:\Windows\Microsoft.NET\Framework\v2.0.50727  (InstallRoles.sql)

Change the line(s) in the scripts:

look for this line: DECLARE @tbNames table(Name nvarchar(256) NOT NULL PRIMARY KEY) and add the collation like specified in the “aspnet_Roles.RoleName” column.  Your new line should look like this:

DECLARE @tbNames table(Name nvarchar(256) COLLATE Latin1_General_CI_AS NOT NULL PRIMARY KEY)

You need to do this for the 2 stored procedures.

Who.I.am

Certified Umbraco, .net and Azure developer, seo lover. Magician in my spare time.

Month List