Sunday, November 18, 2012

How to add text to beginning or end of each line using notepad++

Get your text to modify in notepad++.

Step 1) Bring up the Find/Replace Dialog box by going to menu Search->Replace; or using shortcut CTRL+H.
Step 2) Select the "Regular expression" option in the "Search Mode" section of the dialog box.
Step 3) Enter "^" into the "Find what" textbox. ("^" denotes (matches) beginning of a line in Regular Expression syntax)
Step 4) In this example we will add "http://" to the beginning of each line. So enter "http://" (without double quotes) in the "Replace with" textbox.
Step 5) Press "Replace All" and your text will have "http://" at the beginning of each line.

Similar steps can be followed to add texts to the end of each line. Just use "$" instead of "^". In Regular Expression syntax, "$" matches the end of a line.

Tuesday, November 6, 2012

ASP.NET 4.0 A potentially dangerous Request.Form value was detected from the client.

"A potentially dangerous Request.Form value was detected from the client".

This error happens in ASP.NET when you try to submit text to server which contain HTML Tags. This is a mechanism in ASP.NET environment to safagaurd from cross sire scripting attack.

The error can be suppressed by setting a property to your page directive. The property and its value is as follows:
validateRequest="false" .
So the part of the Page Directive will look like below:
<pages validateRequest="false" />

But with .NET Framework 4.0 and above, the error started showing up again even with the validateRequest property set to "false".
To overcome this error in .NET Framework 4.0 you will need one more step.
You will need to set the "requestValidationMode" property  to "2.0" to the httpRuntime configuration section of the web.config file. The resulting tag will look like:
<httpRuntime requestValidationMode="2.0"/>

If your web.config file does not have a httpRuntime section already, then add it inside the
<system.web> section.

If you want to turn off request validation for users globally, the following line in the web.config file within <system.web> section will help:
<pages validateRequest="false" />