David Huby’s Blog Technical and business stuff

2Mar/100

Add Windows Authentication Provider IIS 7 Windows 7

http://weblogs.asp.net/zroiy/archive/2008/08/17/missing-windows-authentication-provider-for-iis-7-on-windows-server-2008.aspx describes how to set up Windows Authentication providers in IIS 7 on Windows 2008; the image below shows how it's done in Windows 7

Filed under: Sysadmin No Comments
2Mar/100

Event validation error in ASP.NET

I ran into this .NET error yesterday:

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

This article may help if you have a page where the contents of drop down list boxes are being updated after the page has loaded - i.e. with JavaScript.

As K Scott Allen says, "Event validation checks the incoming values in a POST to ensure the values are known, good values. If the runtime sees a value it doesn’t know about, it throws an exception." http://odetocode.com/blogs/scott/archive/2006/03/20/asp-net-event-validation-and-invalid-callback-or-postback-argument.aspx

I had two Drop Down Lists which were being populated via AJAX after page load. The approaches to solving eventValidation errors I saw around on the .NET and StackOverflow:

  • Disable event validation: bad unless you have a workaround for all elements on the page, and some users have said that this has stopped other events firing.
  • Update the Render method: in some cases this will definitely work, in my case - it may be possible that I could have updated the validation with all possible values, something I haven't tried
  • Replace DropDownList controls with select tags: probably not a good idea but could be used for a quick fix
  • Some users have recommended adding an ASP.NET AJAX UpdatePanel around the affected control(s)

In my case I added all possible values of the drop down on page load and removed the AJAX functionality, as a quick fix, because the issue was occurring on a production site.

Filed under: Uncategorized No Comments
1Mar/101

Sitecore CryptographicException: Padding is invalid and cannot be removed.

Something to try if you get the error below: Recycle the application pool for the given website. It worked for me.

Update: If that doesn’t fix your problem, try clearing your cookies.

Server Error in '/' Application.
Padding is invalid and cannot be removed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[CryptographicException: Padding is invalid and cannot be removed.]

Tagged as: 1 Comment
1Mar/100

Sitecore issue – not all users being displayed in the User Manager

I know there more than 15 users should be returned by my providers, but only the first 15 are being displayed in the User Manager.

If I search using a search string such as "a" the results are correctly filtered to those including only "a". Some of the users returned in this result were not displayed in the previous listing. They are valid users and should have appeared when all users were being displayed.

Sometimes the users available shows "Page 1 of 2 (15 of 20 users)". Clicking on the right arrow to view the next page will display a different 15 users and in the bottom right hand corner users available is updated to "Page 2 of 1 (15 items)"

In the release notes for Sitecore,

October 21, 2009
Released Sitecore CMS 6.2.0 rev.091012 (Initial release). Change log. Important Changes:
User Manager
The performance of the User Manager has been improved again after 6.1 Update-1 had removed a previous optimization. This fix will, however, re-introduce the problem that the User Manager in certain situations, for example after creating a new user, will display an incorrect total number of users in the footer.

The Sitecore installation in question is using version 6.1.0 (rev. 090630)

Working theory: we need to update our Sitecore instance.

Filed under: Uncategorized No Comments
26Feb/100

Sitecore tip of the day – Rebuild Lucene Search Index

How do I rebuild a Lucene Search Index in Sitecore?

  • Log in to the Sitecore desktop at http://yoursite/sitecore/
  • Click the Sitecore button and open the Control Panel
  • Click on the Database group
  • Click Rebuild the Search Index
  • Select the indexes you wish to rebuild and click the Rebuild button
3Feb/100

Ed Catmull, Pixar: Keep Your Crises Small

  • Organisational structure should not be confused for communication structure
  • Success hides problems.
  • If you give a good idea to a mediocre group they'll screw it up. If you give a mediocre idea to a good group they'll fix it - or throw it away. (described by Ed as "People and how they function is more important than ideas")
  • When a team functions well together, they will succeed
  • Make something that's broken better rather than copying a success -> taken literally this could be contrary to Al Ries theory of mining the rich gold vein in his book Focus
  • Post mortems should be a critical in depth analysis. Pixar's current post mortem technique is to ask people to give feedback regarding the process they used on that film: 5 things they would do again and 5 things they wouldn't do again
Filed under: Business No Comments
2Feb/101

TortoiseSVN icons not working in Windows 7

I have been having a problem where Tortoise SVN icons have not been appearing in Windows 7, and this seemed to fix my problem.

http://stackoverflow.com/questions/1057734/tortoisesvn-icons-not-showing-up-under-windows-7

Filed under: Programming 1 Comment
1Feb/103

Parsing and analysing IIS W3C log files

There are three methods I've used to parse and analyse IIS W3C log files in the last couple of weeks. AWStats, Log Parser, and SQL Server.

Option 1: Use AWStats

http://awstats.sourceforge.net/

Free real-time logfile analyzer to get advanced statistics (GNU GPL). This can be used on the command line and produces graphs and stats in webpages. To install and get stats from your first log file will probably take 1-2 hours.

Option 2: Use Log Parser 2.2 from Microsoft

http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en

"Most software is designed to accomplish a limited number of specific tasks. Log Parser is different... the number of ways it can be used is limited only by the needs and imagination of the user. The world is your database with Log Parser."

Microsoft, I can't believe you really just said that.

Anyway the Log parser is a handy tool, even more so because you can query log files themselves using SQL like syntax. This one only takes about 10 minutes to download and install, and you can be pulling useful numbers out of it within about 5 minutes.

Option 3: Use SQL Server Management Studio

Create a table similar to the following (depending on the format of your log)

CREATE TABLE [dbo].[tablename] (
[date] [datetime] NULL,
[time] [datetime] NULL ,
[c-ip] [varchar] (50) NULL ,
[cs-method] [varchar] (50) NULL ,
[cs-uri-stem] [varchar] (255) NULL ,
[cs-uri-query] [varchar] (2048) NULL ,
[sc-status] [int] NULL ,
[sc-bytes] [int] NULL ,
[time-taken] [int] NULL ,
[cs(User-Agent)] [varchar] (255) NULL ,
[cs(Cookie)] [varchar] (2048) NULL ,
[cs(Referer)] [varchar] (2048) NULL
)

Populate it using this command

BULK INSERT [dbo].[tablename] FROM 'c:\data\my.log'
WITH (
FIELDTERMINATOR = ' ',
ROWTERMINATOR = '\n'
)

(code taken from http://support.microsoft.com/kb/296085)

If you already have SQL Server Management Studio installed this method is useful, especially due to the familiar syntax (SQL)

Filed under: Sysadmin 3 Comments
27Jan/100

Running Powershell scripts on a new PC

When running Powershell scripts for the first time on a developer PC, you will need to change the execution policy for Powershell.

By default the behaviour only allows signed scripts to run.

Executing

Set-ExecutionPolicy RemoteSigned

will allow locally developed scripts to be executed.

More information about Set-ExecutionPolicy can be found at http://technet.microsoft.com/en-us/library/ee176961.aspx until Microsoft changes their URLs yet again

Filed under: Sysadmin No Comments
23Nov/090

Tool for duplicate code detection

I have spent some time evaluating freeware tools which can identify duplicate code.

I had mixed success with PMD/CPD, phpcpd, and others, until finally I came across Duplicate Code Finder. This is a visual tool compiled into a single 33KB exe, and seems to work perfectly.

Download link - http://www.gaijin.at/en/dldupcodefind.php

Only one downside - all the labels in the tool are in German, so you might need to keep a Google translate window open while you're using it...