Monthly Archives: January 2006 - Page 2

Atlas New RC build released

There is a new Atlas RC available for download. 
This one has got really cool new features.  If you haven’t looked at atlas before you should look at it now.

AJAX just became as simple as 1-2-3.

Nikhil Kothari blogs about the new features :

A quick tour of Atlas December CTP :
http://www.nikhilk.net/AtlasM1.aspx

The role and functionality of the Atlas Scriptmanager :
http://www.nikhilk.net/AtlasScriptManager.aspx

That should get your appetite for AJAX going :-D

MS Antispyware doesn’t do its job

I had a discussion with my friend Miel (Coolz0r) about spyware and their scanners for it. 6 months ago I did a test of several anti-spyware programs and MS antispyware became the winner. It found the most spyware and what I liked most about it was that it provide everything that Ad-aware and Spybot supplied all together. This and the spynet option.  But in 6 months a lot can change and now I have whenU on my machine together with some other heavy duty spyware.  More on the reasons for this you can find in the link below

http://blog.coolz0r.com/posted/microsoft-antispy-downgrades-claria-apps.html

So the search for a good, free spyware cleaner goes on … I’ll post more when I’ve found one.  If anybody has a recommendation please let me know, because spyware me-no-like.

A clear explanation of generics in c# 2.0

http://www.ondotnet.com/pub/a/dotnet/2004/05/17/liberty.html?page=2

Webresource.axd. How do I use it ???

Ever since I got my hands on .NET 2.0 I noticed the handler webresource.axd which seemed to provide a similar function as what I was using handlers for. 

I used handlers in .NET 1.1 and before today also in .NET 2.0 to handle my javascript and css that I need in controls I developped.
I mark them before compiling as embedded resource and then later on read them out via reflection and they get served up by the browser.

I probably don’t have to explain that (as long as your parameters don’t change) this scripts get cached by the browser so they will only be downloaded once and re-used afterwards.

Well in asp.NET 2.0 there is a feature that uses webresource.axd to handle all kinds of embedded resources (images, pages, etc…)

Nikhil Kothari has a post on how to use them in his blog, and I just copy pasted the text below.

Using Web Resources
Imagine I am writing an HtmlEditor control and I want to use a stock bold button icon. Here’s what I’d do:

  1. Embed “Bold.gif” as a resource with the same name into my control’s assembly.
  2. Mark it as Web-accessible via the attribute:
        [assembly: WebResource("Bold.gif", ContentType.ImageGif)]
  3. Use the GetWebResourceUrl() method on Page to get a URL that can be rendered out to the client.
        boldButton.ImageUrl = Page.GetWebResourceUrl(typeof(HtmlEditor), "Bold.gif");

This results in a URL of the form:
    WebResource.axd?a=MyControls&r=Bold.gif&t=632059604175183419

Validation of viewstate failed.

This happens when you want to enable your security to encrypt your password and enable password retrieval.

If you set your own machinekey.

My fix was in the web.config :

<

pages enableViewStateMac=true viewStateEncryptionMode=Always>pages>

<

membership defaultProvider=SqlMembershipProvider hashAlgorithmType=SHA1>
    <
providers>
   providers>
membership>

<

machineKey validation=SHA1 validationKey=8EF2706A98DAB8DFD9DED53180A02BD172A45586AACD63500D5290CF44BACCC1697F402AE0F5D734940BD19BB98A6EBBE788E943B7293E6356B25B00DF2891FB,IsolateApps decryption=AES decryptionKey=8F103358F65FD53132A2856C8BAC9273AA92493D5570945EC74C5856B626BB66,IsolateApps/>

A good url regular expression ?

I have been looking for a good first layer of validating an url to see if it is valid.

For checking the format of the url it seems to me to be the most logical approach to use regular expressions. Up until now I always discarded them as being to “geeky”, meaning i don’t consider it my life’s biggest goal to be typing (/?[]\w) all day long (so why did i become a programmer, aaaah yes to make life easier for other people)

Anyway.. to find a good regular expression to that validates urls not url domains. One that doesn’t allow spaces in the domainname and where the domain can be suffixed with the port number.  Also I need support for the ~/ paths

This is what I came up with.. if somebody as a better idea… or finds a mistake please let me know.. Always happy to learn something new.

^(((ht|f)tps?\:\/\/)|~/|/)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5})(:[\d]{1,5})?)/?(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?

I was a bit quickly in using this regex. Simeon pilgrim indicated that the ftp urls won’t validate when you add a username and a password. 

I don’t really need to validate ftp so I should have removed the ftp protocol from the list of choices.  I need this just to validate urls for weblinks and the link element in an rss feed.  When I need them for ftp I will post the ftp version.. but for now I don’t have time to spend on elaborating the regex.

Anyway here is the right one : ^(http(s?)\:\/\/|~/|/)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?/?(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?

A full url validation would include resolving names through dns or making a webrequest to the provided url to see if we get a 200 response. The only way to be sure is to test if it is there in my opinion.

Thanks Simeon.

And for those who really want the ftp validation : ^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?/?(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?

I am not sure about numbers in the username but I believe you can have a username of numbers alone.

Comments don’t seem to work on this blog engine.. so just send me a mail through the contact form. thanks

Two days later …

I discovered there is still a problem with my regular expressions… folders don’t get parsed.
I’ve solved the path issue, so now it should be finding all url’s

Expression:
^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?

Should parse the url below
http://hh-1hallo.msn.blabla.com:80800/test/test/test.aspx?dd=dd&id=dki

But not :
http://hh-1hallo. msn.blablabla.com:80800/test/test.aspx?dd=dd&id=dki

 

Page 2 of 212