Thursday, February 18, 2010

Potentially dangerous Request.Form value was detected from the client : ValidateRequest

This error is caused because the .NET framework detected HTML in an input control (e.g. TextBox). I've highlighted 3 possible ways to get round the issue, all with their advantages and disadvantages:

1. Add the following to the existing Page directive on the relevant pages.

<%@ Page Language="C#" MasterPageFile="~/Master.master" ValidateRequest="false" AutoEventWireup="true" CodeFile="Default.aspx.cs"
    Inherits="_Default" %>

2. Add the following to the Web.config within the <system.web> section (globally disable request validation). This will allow users to enter HTML into controls which could be harmful or result in undesirable consequences.

<system.web>

<pages validateRequest="false" />

</system.web>

3. Unless you need users to be able to enter HTML into a form, make sure all HTML displayed in controls is encoded.

lblTextBox.Text = HttpUtility.HtmlEncode( lblTextBox.Text );

Thursday, January 07, 2010

List all Tables of Database with No of Rows - SQLSERVER

This will get all the Table Names with no of rows in it.
use YourDBName
Go
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.rows)
FROM
sysobjects so,
sysindexes si
WHERE
so.xtype = 'U'
AND
si.id = OBJECT_ID(so.name)
GROUP BY
so.name
ORDER BY 2 DESC

Friday, December 11, 2009

How to recover lost files in windows 7 and Vista?

Have you ever deleted a file or folder from the desktop and emptied the recycle bin only to realize, seconds later, that you deleted the wrong one? Or have you ever edited a document, saved it, and then wanted to undo those changes?

Luckily, both Windows Vista and Windows 7 include a build-in feature called Shadow Copy that can solve this exact problem without you having to do anything. As you work with the files, Shadow Copy will automatically save incremental backups of your files in the background so if you accidentally delete or change a file, you can revert to the previous version with a simple right-click.

The Shadow Copy feature is available in all editions of Windows 7 but only in the Business and Ultimate editions of Vista. However, if your computer is running Vista Home Basic or Home Premium editions, you can still enjoy the Shadow Copy feature without upgrading your OS.

The feature may also come in handy if your document gets damaged or you want to bring back the files that were deleted by a virus.