Tuesday, August 23, 2011

asp IsValidEmail

Function IsValidEmail(Email As String) As Boolean
If InStr(1, Email, ".") = 0 Then
IsValidEmail = False
Exit Function
End If

If InStr(1, Email, "@") = 0 Then
IsValidEmail = False
Exit Function
End If
IsValidEmail = True
End Function

Function FormatTime(TimeElapsed As Integer) As String
Dim Seconds As Integer
Dim Minutes As Integer
Dim Hours As Integer

'Find The Seconds
Seconds = TimeElapsed Mod 60

'Find The Minutes
Minutes = (TimeElapsed \ 60) Mod 60

'Find The Hours
Hours = (TimeElapsed \ 3600)

'Format The Time
If Hours > 0 Then
FormatTime = Format(Hours,"00") & ":"
End If
FormatTime = Format(Hours, "00") & ":"
FormatTime = FormatTime & Format(Minutes, "00") & ":"
FormatTime = FormatTime & Format(Seconds, "00")
End Function

Monday, August 1, 2011

cmd As Administrator -> cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319 -> aspnet_regiis -i

If you’re new to IIS 7 (you probably are) you might receive this nice little gem when you first start working with it:

HTTP Error 500.19 – Internal Server Error
Description: The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code: 0×80070021
Notification: BeginRequest
Module: IIS Web Core
Requested URL: http://localhost:80/ExampleApplication/
Physical Path: C:\inetpub\wwwroot\ExampleApplication\
Logon User: Not yet determined
Logon Method: Not yet determined
Handler: Not yet determined
Config Error: This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.
FONT color=#a52a2a>
Config File: \\?\C:\inetpub\wwwroot\ExampleApplication\web.config
Config Source:
  184:      185:      186:     

IIS 7 implements “Configuration Locking“. This is to help with IIS administration. The IIS Administrator can lock down Configuration Sections, Section Elements and Attributes at the IIS level. This allows the administrator to have a more granular level of control on the system. Read this link to see more about it.

Important Note: In order make these changes, you must be an administrator on the machine where the config file resides. If its on your local machine, you must be an administrator on your machine.

Since I’m on my own development machine, and since this is a development machine, I have decided to change the global setting (the config section itselft). To fix this error I had to go to the applicaitonHost.config file and set the overrideModeDefault to “Allow”.

Here’s how:

Open the applicationHost.config file, located here: %windir%\system32\inetsrv\config\applicationHost.config

In my instance, I need to edit the “handlers” section.

Change this line:

Deny” />

To:

Allow” />

Thats it. :)


You might receive more errors after you enable this, such as the same error for modules, but just follow the same steps above, and you should be good.

Note: You can accomplish this same thing through the command line by using the appcmd.exe application (%windir%\system32\inetsrv\appcmd.exe). Like this:

%windir%\system32\inetsrv\appcmd unlock config -section:system.webServer/handlers

One more note…

This is not something you’d want to do on a production server unless you’re sure you want to enable all appliations to override the section contents. Be sure to read up on some of the docs (explanation of the configuration system) before you make this change on production.