09 Mar 2008

ASP.NET MVC Preview 2 CAPTCHA using ActionFilterAttribute

42 Comments Uncategorized

My last article on ASP.NET MVC CAPTCHA was very well received by many of my readers and it even caught the eye of the DotNetKicks crowd. Now that MVC Preview 2 was released last week, many new features make encapsulating my CAPTCHA control even easier. Most notably is the ActionFilterAttribute which allows you to override the Pre and Post action events for any action the attribute is applied to.

Basically everything works the same as it did in the previous article. I just modified things for MVC Preview 2. To validate the CAPTCHA you add the attribute CaptchaValidation to the action.

[CaptchaValidation("captcha")]
public void Register(string userName, string password, string email, string question, string answer, bool captchaValid){
    // do stuff
}

You still need to register the CAPTCHA image handler.

<httpHandlers>
    <add verb="GET" path="captcha.ashx" validate="false" type="ManagedFusion.Web.Handlers.CaptchaImageHandler, ManagedFusion" />
</httpHandlers>

I added an extension to HtmlHelper that generates a text box with autocomplete=”off”.

<label for="captcha">Enter <%= Html.CaptchaImage(50, 180) %> Below</label><br />
<%= Html.CaptchaTextBox("captcha") %>

Which generates the following.

Example of CAPTCHA

You can view the source code for this on my Google Code Project, everything is available through SVN.

  1. CaptchaValidationAttribute.cs
  2. CaptchaHelper.cs
  3. CaptchaImage.cs
  4. CaptchaImageHandler.cs

Or you can download the project for you own personal use.

19 Nov 2007

TF220064 – Team Foundation Server 2008 – Reporting Service Permissions

6 Comments Uncategorized

I decided to be one of those early installers that brave the RTM and hope everything has been programed correctly, so my current system doesn’t get blown away in the upgrade process. I have a small in home Team Foundation Server that I use for my home based business and personal coding. So an upgrade is pretty risky, in that I risk loosing everything. Knowing all the risks I decided to move forward and everything was going smoothly with installing Visual Studio 2008 Team Foundation Server, until I ran in to the follow problem.

—————————
Microsoft Visual Studio 2008 Team Foundation Server Setup
—————————
TF220064: An error occurred while the Setup program was querying the settings from the server that is running SQL Server Reporting Services. This error is most likely caused by your account not having the required administrative permissions on the server that is running Reporting Services. Click Next to try again. For more information about this error, see the installation logs. For more information about the installation logs, see “Troubleshooting Installation for Team Foundation” in the Team Foundation Installation Guide.
—————————
OK
—————————

The document above told me to reference this file Drive:\Documents and Settings\SetupAccount\Local Settings\Temp \dd_install_vstf_tfc_90.txt. I found the following reference at the bottom of the log file.

[11/19/07,21:01:32] TFSUI: getcurrenttfsproperties.exe: — STATUS: TfsIntegration..tbl_service_interface has at least one row in it
[11/19/07,21:01:32] TFSUI: getcurrenttfsproperties.exe: — STATUS: Found Reports.ReportsService=http://team.coderjournal.com/ReportServer/ReportService.asmx
[11/19/07,21:01:32] TFSUI: getcurrenttfsproperties.exe: — STATUS: Writing VSTF_RS_SERVER=team.coderjournal.com into C:\Documents and Settings\nick\Local Settings\Temp\SIT41264.tmp\TfsCurrConfig.ini section Config
[11/19/07,21:01:32] Setup.exe: AddGlobalCustomProperty
[11/19/07,21:01:32] TFSUI: ***ERRORLOG EVENT*** : getcurrenttfsproperties.exe: *** ERROR: Failed to call WMI on the RS server. The most likely cause is that the setup user does not have the required permissions: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESSDENIED))
[11/19/07,21:01:32] Setup.exe: AddGlobalCustomProperty
[11/19/07,21:01:32] TFSUI: ***ERRORLOG EVENT*** : getcurrenttfsproperties.exe: at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
[11/19/07,21:01:32] Setup.exe: AddGlobalCustomProperty
[11/19/07,21:01:32] TFSUI: ***ERRORLOG EVENT*** : getcurrenttfsproperties.exe: at System.Management.ManagementScope.InitializeGuts(Object o)
[11/19/07,21:01:32] Setup.exe: AddGlobalCustomProperty
[11/19/07,21:01:32] TFSUI: ***ERRORLOG EVENT*** : getcurrenttfsproperties.exe: at System.Management.ManagementScope.Initialize()
[11/19/07,21:01:32] Setup.exe: AddGlobalCustomProperty
[11/19/07,21:01:32] TFSUI: ***ERRORLOG EVENT*** : getcurrenttfsproperties.exe: at System.Management.ManagementScope.Connect()
[11/19/07,21:01:32] Setup.exe: AddGlobalCustomProperty
[11/19/07,21:01:32] TFSUI: ***ERRORLOG EVENT*** : getcurrenttfsproperties.exe: at GetCurrentTfsProperties.WmiHelper.FindAllInstancesOfClass(String wmiNamespace, String wmiClass)
[11/19/07,21:01:32] Setup.exe: AddGlobalCustomProperty
[11/19/07,21:01:32] TFSUI: ***ERRORLOG EVENT*** : getcurrenttfsproperties.exe: at GetCurrentTfsProperties.WmiHelper.FindSqlRsInstance(String reportServerHostname, String databaseInstanceName, String dataSourceString)
[11/19/07,21:01:32] TFSUI: getcurrenttfsproperties.exe: Process exited with exit code: 15[11/19/07,21:01:32] TFSUI: Done calling CheckExistingTfsInstallation in GetTfsPropertiesFromDt
[11/19/07,21:01:32] vs70uimgr: Entering DisplayMessage() method.
[11/19/07,21:01:32] vs70uimgr: DisplayMessage_START:TF220064: An error occurred while the Setup program was querying the settings from the server that is running SQL Server Reporting Services. This error is most likely caused by your account not having the required administrative permissions on the server that is running Reporting Services. Click Next to try again. For more information about this error, see the installation logs. For more information about the installation logs, see “Troubleshooting Installation for Team Foundation” in the Team Foundation Installation Guide.
[11/19/07,21:01:33] vs70uimgr: DisplayMessage_END:TF220064: An error occurred while the Setup program was querying the settings from the server that is running SQL Server Reporting Services. This error is most likely caused by your account not having the required administrative permissions on the server that is running Reporting Services. Click Next to try again. For more information about this error, see the installation logs. For more information about the installation logs, see “Troubleshooting Installation for Team Foundation” in the Team Foundation Installation Guide.

From what I could tell the problem was in the database TfsIntegration..tbl_service_interface and had something to do with the follow record.

3 ReportsService http://team.coderjournal.com/ReportServer/ReportService.asmx

So on a hunch I just changed the above to. (TEAM-SERVER is the name of my server)

3 ReportsService http://TEAM-SERVER/ReportServer/ReportService.asmx

Then I continued with the installation and everything proceeded as Microsoft envisioned.

19 Nov 2007

Visual Studio 2008 and .NET 3.5 Released

No Comments Uncategorized

Scott Guthrie has announced that Visual Studio 2008 and .NET 3.5 are now available for download and provides a tour of some of the new features.

  • If you are a MSDN subscriber, you can download your copy from the MSDN subscription site (note: some of the builds are just finishing being uploaded now – so check back later during the day if you don’t see it yet).
  • If you are a non-MSDN subscriber, you can download a 90-day free trial edition of Visual Studio 2008 Team Suite here. A 90-day trial edition of Visual Studio 2008 Professional (which will be a slightly smaller download) will be available next week. A 90-day free trial edition of Team Foundation Server can also be downloaded here.
  • If you want to use the free Visual Studio 2008 Express editions (which are much smaller and totally free), you can download them here.
  • If you want to just install the .NET Framework 3.5 runtime, you can download it here.