February 2007 - Posts

These instructions show how to stop the McAfee Anti-Virus 8.5i splash screen appearing everytime you start Windows.

WARNING: You should backup your files before editing the registry. If you use Registry Editor incorrectly, you can cause serious problems that may require you to reinstall your operating system.  Use Registry Editor at your own risk.

  • You may need to first temporarily disable McAfee from blocking changes to McAfee settings.
  • To do this, open the McAfee VirusScan Console and right-click on Access Protection and select Properties.
  • Select Common Standard Protection and uncheck Block for Prevent Modification of McAfee Files and Settings. Click Apply.
  • Run regedit
  • Navigate down to HKEY_LOCAL_MACHINE\Software\McAfee\DesktopProtection   
  • Double click bSkipSplash.
  • A "DWORD Editor" window will appear. To skip the splash screen set the value to 1 by entering 1 then clicking OK.

Don't forget to re-check the block setting for "Prevent Modification of McAfee Files and Settings" in the VirusScan console.

 

Posted by gcastner | with no comments

Here is a code snippet for detecting in which Internet browser a user is viewing your site.

Note that I usually use two stylesheets. The first, standard.css, contains the styles interpreted the same way by all browsers. I then use a second stylesheet to add or change any styles rendered differently in different browsers.

In the head tag of the relevant page (a .master page would be a good location) add the following lines (assuming that you use two stylesheets as described above):

<link href="/styles/standard.css" rel="stylesheet" type="text/css" />
<link runat="server" rel="stylesheet" type="text/css" id="stylesheet2" />

In the page_load sub of the same page, add the following code:

'Determine the correct css file depending on the browser

Dim httprequest1 As HttpBrowserCapabilities = Request.Browser

Select Case httprequest1.Browser

Case "IE"
   If httprequest1.Version = "6.0" Then
      stylesheet2.href = "ie6.css"
   End If

Case "Firefox", "Mozilla"
   stylesheet2.href = "firefox.css"

Case Else
   stylesheet2.Href = ""

End Select

In this example, only two browsers are detected but you could of course add more. You can also add additional versions to each browser.

Posted by gcastner | with no comments

ASP.NET 2 includes the FileUpload control to make it easier to create pages that allow users to upload files. The default maximum file size is 4096 KB to minimize the potential for denial of service attacks. You can change the maximum file size by editing your configuration files (see for example http://msdn2.microsoft.com/en-US/library/system.web.configuration.httpruntimesection.maxrequestlength(VS.80).aspx and http://support.softartisans.com/kbview_825.aspx).

The problem is that when users attempt to upload a file that is too large, it is difficult to capture and handle the exception that is created. The usual try..catch doesn't handle the exception because the exception occurs before then. The exception is "System.Web.HttpException: Maximum request length exceeded". You could of course increase the maximum file size but that defeats the purpose of the limit in the first place.

Here is one solution for handling the exception that is at least nicer than the standard ASP.NET exception message:

1. Create a global.asax file. If you're using Visual Studio 2005 it will set up a number of common subroutines for you. You need to use Sub Application_Error. Your code should look something like this:

<script runat="server">
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim currentException As Exception
currentException = Server.GetLastError.GetBaseException()
Response.Redirect("/error.aspx?Err=" & Server.UrlEncode(currentException.Message))
End Sub
</script>

The application_Error sub fires as a last resort, in other words, when you haven't explicitly handled the exception anywhere else in your code.

2. You can now create an error.aspx that displays the exception message (from the querystring). For this exception the message is "Maximum request length exceeded". You could also test for the message and give users more information on the error.

Please let me know if you have any comments, suggestions, or improvements.

Posted by gcastner | with no comments

Here are a number of simple but useful functions for manipulating text in Microsoft Excel. One potential use of these functions is to separate last and first name when they are stored in a single cell. An example Excel file is also attached.

This formula will return the first five characters from the left in cell A2:

=LEFT(A2,5)

This formula will return the total number of characters (including spaces) in cell A2:

=LEN(A2)

This formula will return the number of characters (including spaces) from the left until the first space in cell A2:

=FIND(" ",A2)

To find first names where first name and last name are separated by a space:

=LEFT(A2,FIND(" ",A2)-1)

To find last Names where first name and last name are separated by a space:

=RIGHT(A2,LEN(A2)-FIND(" ",A2))

Posted by gcastner | with no comments