in

dotNetFreak

Ramblings & Controls from a .NET Addicted Freak!

Kevin Gearing's Blog

  • Windows SharePoint Services, Documents & Username/Password Prompts

    Putting an intranet live using Windows SharePoint Services (WSS) was probably one of the better ideas I had last year, however there is one thing that over time has become more and more annoying and that is the username and password prompt that is always displayed when opening a document (whether it is Word, Excel, Publisher or PowerPoint) in either read only or edit mode.

    After being grumbled at for the 100th time this week, I thought it was about time that I got to the bottom of it - I had tried before, but nothing seemed to make a difference and it wasn't that high on the priority list.

    Eventually I stumbled across a Microsoft KB article (http://support.microsoft.com/?id=943280) which outlined the cause of the problem - IE + Vista and a site that uses a FQDN.

    It would appear that the WebClient/WinHTTP service ignores the security zone settings within IE which would explain why previous solutions I've read on this problem never seemed to work for me (they all revolved around making changes to the IE configuration), well unless you wanted to make IE exceptionally insecure that is...

    It's worth noting that the registry changes still worked even though the machines were running Vista SP1 and some of the file dates/versions were lower than those listed within the article.

    Oh... don't forget to restart the WebClient service (I missed that first time around)... 

    Anyhow, yet another little problem fixed.

  • ASP, w3wp.exe, Disappearing Memory and McAfee VirusScan Enterprise (Again!)

    Following on from my post back in 2005 (ASP.NET, w3wp.exe, 100% CPU Usage and McAfee VirusScan Enterprise) I recently noticed a particular Web server "drinking" what appeared to be an excessive amount of memory.

    In fact I was seeing < 100MB physical memory available and the page file usage at approximately 9-10GB on a server that currently has 4GB of RAM and that isn't normally stressed at all.

    As this server hosts a number of Web sites in seperate application pools firing up Task Manager revealed some interesting results. I could see most application pools consuming 8-10MB of RAM each, some consuming 30-40MB, but quite a few consuming > 100MB with a couple consuming over 150MB.

    I started to tie the application pools back to the individual Web sites and look at the type of content that they were serving, whether it was static or dynamic, ASP, ASP.NET or PHP, whether they were using Access, MySQL or SQL Server databases and whether they were typically busy Web sites.

    One thing became immediately apparent, the memory boozers were all ASP driven...

    My initial reaction was to stop all McAfee services (always blame the anti-virus software first!) and to see what happened, so after doing this and a quick iisreset I fired up Task Manager again and waited... Sure enough 10 minutes later I was seeing application pools running at > 100MB.

    So, thinking that the AV software wasn't to blame I spent the next hour or so checking everything else I could think of.

    In the end I turned to the IIS Diagnostics Toolkit (if you haven't seen this check it out!) and dumped a couple of the w3wp.exe processes, within a couple of minutes I was staring at a report which quite obviously was pointing the finger at one of the McAfee modules that was utilising 120MB of the process. After repeating this on a few other processes, all with similar results, I then had to set about working out which part of McAfee was to "blame".

    Eventually this led me to the ScriptScan setting within McAfee VirusScan, which is described as...

    "ScriptScan scans JavaScript and VBScript scripts that are executed by the Windows Scripting Host.  WSH is used by Internet Explorer and Outlook.  If an unwanted script is detected it is not allowed to execute."

    Hmmm...

    So a quick disable (well, actually not that quick as the AV policies are centrally managed and have to be propogated down to server level from a management console), an iisreset later and I'm closely watching Task Manager as the application pools start firing up... 10 minutes later I'm still watching... 15 minutes... time for a coffee... 30 minutes later and I'm seeing no application pools above 100MB, the vast majority at 8-20MB and the rest at 30-40MB with a couple busier sites running at 50-60MB.

    Available memory has suddenly increased from < 100MB to > 2.5GB and the page file usage is down to 2GB.

    Re-enabling ScriptScan proves that this "feature" is the problem...

    So why is a feature related to Windows Scripting Host, interfering with a process that is excluded from scanning, when the AV services are stopped?

    Well, if I knew the answer to that I could probably predict lottery numbers...

  • FormShield & IIS 7

    Yes, I'm still around! - but I have been pretty busy at work over the last few months, however as FormShield and IIS 7 keeps coming up, I thought it was about time that I added a quick blog post!

    The good news is that FormShield works fine with IIS 7, but you do need to make a configuration change...

    You can either change the application pool that the Web site uses to the Classic .NET application pool or move the <httpHandlers> section under <system.web> of the web.config file to the new IIS 7 <handlers> section under <system.webServer>.

    i.e. change:

    <system.web>

    <httpHandlers> <add path="FormShield.aspx" verb="GET" type="dotNetFreak.WebControls.FormShieldHttpHandler, dotNetFreak.WebControls.FormShield" />

    </httpHandlers>

    </system.web>

    to:

    <system.webServer>

    <handlers>

    <add name="FormShieldHttpHandler" path="FormShield.aspx" verb="GET" type="dotNetFreak.WebControls.FormShieldHttpHandler" resourceType="Unspecified" />

    </handlers>

    </system.webServer>

    and it should work fine.

    Thanks to Nick Eales and Mike Sloan for pointing this out.

    Also, a good article on ASP.NET integration with IIS 7 can be found at: http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis7/

  • How to Donate

    A few people have asked me recently how they actually donate for FormShield and I must admit it isn't exactly obvious. There is a PayPal button on the main FormShield article, but it is a bit buried!

    So, for anyone who would like to donate, here is the link:

     

    Once your donation is received I will drop you an e-mail with a license key that removes the 'dotNetFreak.co.uk' adverts.

    This e-mail isn't sent automatically, and whilst I do endeavour to send them out the same day you donate, I'm not always able to do so, and on occasion it may take a couple of days before you receive your key!

  • FormShield v2.0.1 Released

    FormShield v2.0.1 has been released. Click here for details.

  • Adding a License Key to FormShield

    If you're reading this, you've probably sent a donation for FormShield - Thank you - It's much appreciated!

    Ok, follow the instructions below to add the license key you've been e-mailed to FormShield:

    Open up your 'web.config' file and where you currently have:

    <appSettings>
    <add key="formShield_SecretKey" value="!--FormShield--!" />

    </appSettings>

    add the following directly beneath the 'formShield_SecretKey' line (not instead of!), replacing 'MyKey' with the key that was e-mailed to you (leave the double quotes in place).

    <add key="formShield_LicenseKey" value="MyKey" />

    That's it.

    Save and upload the web.config file and FormShield will no longer render the 'dotNetFreak.co.uk' adverts.

    Thanks again for donating!

  • Adding FormShield to Community Server 2007 - Blog Comments

    Adding FormShield to the blog comments area of Community Server 2007 is fairly straightforward.

    Brief instructions are below, I've also uploaded a copy of the 'post.aspx' and 'web.config' files showing these changes to here.


    1. Download the 'web.config' file for the site and add the following before <connectionStrings ... />:

    <appSettings>
    <add key="formShield_SecretKey" value="!--FormShield--!" />

    </appSettings>


    2. Also in the 'web.config' file, add the following in the <httpHandlers ... /> area:

    <add verb="GET" path="FormShield.aspx" type="dotNetFreak.WebControls.FormShieldHttpHandler, dotNetFreak.WebControls.FormShield" />


    3. Copy the 'dotNetFreak.WebControls.FormShield.dll' and 'dotNetFreak.WebControls.FormShield.BritishMale8kHz8bitMonoWavSoundLibrary.dll' files to the 'bin' directory.


    4. Download the 'post.aspx' file for the theme you are using - e.g. '/Themes/Blogs/default/post.aspx'.


    5. At the top of the file underneath '<% Page Language="C#" ... /> add:

    <%@ Register Assembly="dotNetFreak.WebControls.FormShield" Namespace="dotNetFreak.WebControls" TagPrefix="dnf" %>


    6. Scroll down in the file until you see:

    <div class="CommonFormField" id="Remember" runat="server">

    <asp:CheckBox id="chkRemember" runat="server" Text="Remember Me?" />

    </div>


    Then add the following directly beneath it:

    <div>

    <br />

    <dnf:FormShield ID="FormShield1" runat="server" HttpHandlerPath="/FormShield.aspx" PersistenceMethod="ControlState">

    <RefreshIcon AlternateText="Refresh" />

    <SoundIcon AlternateText="Listen" />

    <HelpIcon AlternateText="Please enter the characters shown on the image" />

    </dnf:FormShield>

    <br /><br />

    Code: <asp:TextBox ID="TextBox1" width="208px" runat="server" />

    <br /><br />

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Please enter the code." Display="Dynamic" ValidationGroup="CreateCommentForm" />

    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="FormShield1" ControlToValidate="TextBox1" EnableClientScript="False" ErrorMessage="Invalid code entered." Display="Dynamic" ValidationGroup="CreateCommentForm" />

    <br />

    </div>


    7. Save and upload the files and you are done!

  • Firefox, BinaryWrite and Compression

    Whilst writing the sound support for FormShield v2, I came across quite an interesting issue, well it was interesting once I'd found the answer, but up until then I wasn't in the best of moods.

    Basically, FormShield uses the BinaryWrite() method to write an audio file to the requesting browser to provide sound support. The issue was that this worked fine in IE, Safari and Opera, but for some reason Firefox didn't seem to like it.

    The strange thing about it was that it would play the first x number of characters, but then stop. On a Mac, it would only play the first character before giving up.

    Thinking that it must be something to do with how I was writing the file out, or perhaps the file size, or even my code that builds the sound file, I started to pull the code apart.

    A few hours later, I was no further forward.

    I came to the conclusion that it couldn't be my code, after all, writing images out this way seemed to work fine in every browser.

    So, I started to look around the problem. I then stumbled across an old post related to writing out PDF files on the fly using BinaryWrite and whilst the issue didn't see to be the same, or affect the same browser (they were talking about IE), one word was mentioned that rang a bell - "Compression".

    I suddenly remembered that HTTP compression was enabled in IIS on this particular server - Quickly turning it off and running an 'iisreset' and testing resulted in a perfect playback.

    Thankfully all of the code I changed was only a CTRL-Z away from being put back to how it was originally and 10 minutes later I retested it and it worked fine.

    So, why does HTTP compression in IIS only break Firefox? No idea - After spending seven hours on the problem I really couldn't care.

  • FormShield and Donationware

    One question I'm bound to be asked is why have I made FormShield v2.0 donationware rather than commercial and why haven't I continued to offer it for free.

    Well, starting at the end first - FormShield is still totally free for personal and commercial use and you are still able to distribute it with your applications without 'donating' a penny (or dime), providing you don't charge for it of course!


    Ok, so if it's free why the 'dotNetFreak.co.uk adverts'?

    Well, when something is offered for free (or donationware), it's too easy to just take it, use it and forget about it. I've done it, you've done, everyone does it. By having a couple of 'gentle' reminders, it prompts us to think "Actually I do use this a lot more than I initially thought, I'm going to pay something for this". Of course that's the idea, whether it works or not is another matter!

    If it doesn't, I should at least end up with more people using FormShield and hopefully some of them will donate!


    Why donationware?

     The idea behind making FormShield donationware is simple:

    • Some people have suggested it as they would like to contribute towards future development of FormShield and other controls.
    • FormShield is a complex control and because of this it has taken a large amount of time to create.
    • I don't get paid for doing this - in fact it actually costs me money!
    • I didn't want to restrict the overall functionality of FormShield.


    Why not commercial?

    The problem with making anything commercial is it removes it from the realm of being a hobby which is all my controls are at the end of day. Yes, they were initially written for other projects, but those projects didn't need me to write new versions. Also, I don't have time to support another commercial venture, I spend most of my time working as it is! I also hate writing documentation and examples, both of which I would need to do to make FormShield commercial.

    I also didn't want to stop the smaller Web sites and hobbyists from using FormShield because they couldn't afford to pay the 'commercial' (per Web site in some cases) license fees.


    Right, so it's totally free if I don't mind the occasional 'dotNetFreak.co.uk' advert?

    Yep.


    Are all of your existing controls and future controls moving to donationware?

    No. Only FormShield, but if you want to send a donation for the others please feel free!

    If I release future controls (quite likely as I'm starting a new project shortly which will probably require custom controls) they may or may not be donationware. More than likely the first versions won't be.


    I want to donate - How much?

    Firstly, thank you!

    Secondly, whatever you want. Its not that I don't care how much you donate, I don't know your circumstances or how widely you use my controls. If you're working for a Web design agency and you use my controls on two hundred Web sites, perhaps you should be thinking more than the one guy who adds it to his blog, but at the end of the day it's entirely up to you, I'm just happy you're going to donate!

  • FormShield for .NET 2.0 Released

    FormShield started out as a simple project with just one aim - to prevent automated form submission using dynamically generated images.

    Not exactly a new idea - dynamically generated images requiring the user to enter the text found on the image have been around for quite a while, preventing automated sign-ups to free e-mail services such as HotMail and Yahoo, and automated whois lookups on domain names on sites such as Network Solutions.

    Whilst some code exists on Code Project, there didn't however seem to be a free, easy-to-use and customisable control for ASP.NET with full designer integration that could generate the relevant images. So, looking for an excuse to delve into GDI+, FormShield was born and my idea of a 'simple' control was dropped...

    ... That was 2004 and this is now...

    Version 2 of FormShield builds on the previous .NET 1.1 version, adding a wealth of new features, options and accessibility improvements. The most notable feature addition is the capability for FormShield to now automatically generate a spoken version of the value shown on the image to aid with accessibility legal compliance. This however is just one of a handful of major new features, not to mention the number of improvements and changes made since the previous version.

    However, whilst a lot has changed, FormShield remains true to its original goals - to be 'easy-to-use', 'customisable' and to have 'full designer integration'.

    No other .NET captcha control currently on the market has the number of features of FormShield, but more importantly, none of them are as customisable or have such a rich design-time experience when used in Visual Studio.

    For more information, check out What's New in Version 2.0.


    Features:

    • Generates BMP, GIF, JPEG or PNG images.
    • Choose the pixel format and smoothing mode used to render the image.
    • Set the height and width of the image as well as the alternate text displayed.
    • Image is built using 3 layers - Background, foreground and noise.
    • Provides 5 fill styles, 5 gradient styles, 54 hatch styles and 2 colors for each layer.
    • Set the length (static or random*) and case (lower, mixed or upper) of the automatically generated text.
    • Ability to set your own text for FormShield to use and the ability to regenerate or automatically change it on postback*.
    • Choose the type of characters you want to use to generate the text (alpha, numeric, symbols, a combination, or random).
    • Choose the fonts (when using a font based text effect) you want to use to draw the text (26 as default) as well as the font style (5 combinable styles, 17 in total).
    • Choose the default, static font to use to draw the text when not using a font based text effect*.
    • Pick a text effect (5 combinable effects, 25 in total) and decrease the noise level to decrease readability.
    • Draw a border around the image using one of 5 styles and your choice of color and width.
    • Randomise the fill style, gradient style, hatch style, font style, text case, character type, text effect and border style.
    • 6 Presets included; Default, Fire, Forest, Sand, Sea and ChessBoard.
    • Supports 4 persistent methods; ViewState, ControlState*, SessionState or HiddenField - ideal if ViewState and/or SessionState aren't available to persist property values on postback.
    • Values stored using any of the persistent methods are automatically encrypted for additional security (128 bit encryption*) with the ability to add your own key to the web.config file*.
    • ValidFrom and ExpiresAfter properties to set how many seconds have to pass before the image is valid and how many seconds after which the image has expired* - Prevent replay attacks.
    • ImageClick event raised when someone clicks on the image (supports Regenerate to generate a new value, BubbleEvent to bubble the event for custom handling or both)*.
    • Full embedded sound support (2 voices as standard, 8bit or 16bit and 8kHz or 16kHz - all selectable) - Will prompt to download the audio file if no plugin is installed.*
    • SoundLibraries distributed seperately so you only need to copy the one you require to your bin directory.*
    • Three additional icons rendered with customisable properties (AlternateText, Height, Width, IconUrl, Visible). Renders default icons if IconUrl is empty.*
    • Refresh icon to automatically regenerate the text value (can also raise an event for custom handling), Sound icon for built in audio playback and Help icon with customisable DestinationUrl property.*
    • Image and sound is rendered on demand (via an HttpHandler*), not saved as a file and audio files support caching (with an encrypted filename)*.
    • Encrypts the querystring (128 bit*) to prevent deciphering by reading the HTML source.
    • Works with existing ASP.NET validation controls as well as StringCompareValidator.
    • Can be used on standalone WebForms as well as UserControls.
    • Supports Community Server 2007* and .Text Blogging Engine to prevent spam on blogs.
    • Tested in IE6 & IE7 (PC), IE5 (Mac), FireFox 2 (PC & Mac), Safari 2 (Mac), Safari 3 (PC), Opera 9 (PC)*
    • Full, rich, Visual Studio .NET designer integration, including rendering whilst in design mode and menu options to automatically add configuration settings to the web.config file.
    • Works in a 'ViewState Disabled' environment. 
    • Compatible with Medium Trust environments*.

    * New in Version 2.

    Simple Online Demo (also see the comments section below)
     

    Screenshots:

         


    Design Time:


    Properties Screenshot 1 | 2 | 3


    Visual Studio .NET Design Time Notes:

    1. To get the image to appear when you first drag 'n' drop FormShield to your page, right click on the control and select both 'Add Secret Key' and 'Add HttpHandler', then save the file and right click on a blank space on the page and click 'Refresh'. If that doesn't work, hit the page in a Web browser and repeat the refresh process. You may also need to open, save and close the web.config file.

    2. On occasion the image doesn't reflect property changes made within the property grid. This seems to be either an issue with Visual Studio, or caching. The easiest way to solve the problem (if it happens in the first place) is to save the file and to repeat the refresh process described above. If you are changing image design properties you can also try placing your mouse cursor into the relevant dropdown list and use the cursor keys to navigate through the options.


    Usage:

    Simply download, add to your toolbox, drag 'n' drop to your page and set the relevant properties using the property grid.

    To combine with a validation control (e.g. StringCompareValidator), add the validation control as well as a TextBox to your page, set the StringCompareValidator's 'ControlToCompare' property to point to the FormShield control and the 'ControlToValidate' property to point to the TextBox control. You will also need to set 'EnableClientScript' to False on the validator if 'EncryptQueryString' is set to True on the FormShield control.

    To change the HttpHandler name/path, update your web.config file and change the HttpHandlerPath property value to point to the new handler.

    To specify your own secret key for encryption, add/change the 'formShield_SecretKey' AppSetting in the web.config file.


    Licensing & Download:

    FormShield v2 is released as 'Donationware', for more information, please click here.

    However - You don't have to donate unless you want to - FormShield can still be used for free for both personal and commercial use, however it will periodically (about 10% of the time) render 'dotNetFreak.co.uk' as the image text and will play 'This control is provided by www.dotnetfreak.co.uk' before the text value when someone clicks on the sound icon (again, about 10% of the time).

    If you do decide to donate (thank you!), you will be e-mailed a license key as soon as possible with instructions on how to add it to FormShield so that it removes the 'dotNetFreak.co.uk' adverts.

    Whether you have donated or not, you may also redistribute the control royalty free, providing that you don't charge for it. Also, if you intend to distribute the control as part of an application which is publicly available it would be nice to know, although this isn't a requirement.

    Got a good image design? Drop me a line using the contact link and I'll look to include it as a preset. 

    To download, please visit the 'Downloads' area.

     


    Help & Support:

    Please post in the forum.

     

    Revision History: 

    Updated 17/07/2007 (v2.0.1):

    • AddUpperLower property added to enable/disable the adding of 'Uppercase' or 'Lowercase' before each character when the sound is played.
    • MultiView design-time issue ('control collection cannot be modified during databind...') - Fixed.

    To use this version you will also need to download v1.0.1 of the Sound Libraries.

    Updated 13/07/2007 (v2.0.0):

    Click here for the changes in this version. 

    For the previous .NET 1.1 version, please click here.

  • FormShield v2.0 & Community Server 2007

    If you check out the comments section today you're bound to have a nice surprise!

    Ok, to the point - FormShield v2 has been added to my Community Server 2007 installation and is working a treat.

  • FormShield v2.0 FINAL Built

    Just a quick post to let everyone know that the release version of FormShield v2.0 is now built.

    I was intending to release it yesterday, but two things happened - 1. I found a small issue whilst testing and 2. I was persuaded to go and see Die Hard 4.0! (Sorry!)

    Just got to finish off a simple demo, zip it all up and create some content and it will be here!

  • Shared Variables - Object Reference Not Set to an Instance of an Object

    Can someone please explain why this throws an exception?

    What's even stranger, is that in one class where I do something similar to this four times, three work fine, but the other one throws an exception...

    Partial Class Strangeness

    Inherits System.Web.UI.Page

    Private _alphaCharacters() As String = MyDefaults.AlphaCharacters

    Public ReadOnly Property AlphaCharacters() As String()

    Get

    Return _alphaCharacters

    End Get

    End Property


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Response.Write(Me.AlphaCharacters.Length)

    End Sub


    End Class


    Public
    Class MyDefaults


    Public Shared ReadOnly AlphaCharacters() As String = MyDefaults.DefaultAlphaCharacters
    Public Shared ReadOnly DefaultAlphaCharacters() As String = {"A", "B"}

    End Class

  • StringCompareValidator v2.0.2 Released

    StringCompareValidator v2.0.2 has been released. Click here for details.

  • CasedTextBox v2.0.2 Released

    CasedTextBox v2.0.2 has been released. Click here for details.

More Posts Next page »
Copyright ©2004-2007 Kevin Gearing. All Rights Reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems