Thursday, November 7, 2013

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

if you are getting this error then we need to add validaterequest="false" line in web page like

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

Tuesday, November 5, 2013

encrypt and decrypt connectionstring in web config

string connectionString = "data source=123.456.789.00,1234\\abcdb;database=databasename;uid=sa;pwd=123";
            Byte[] a = System.Text.ASCIIEncoding.ASCII.GetBytes(connectionString);
            string encryptedConnectionString = Convert.ToBase64String(a);
         
            Byte[] b = Convert.FromBase64String(ConfigurationSettings.AppSettings["defaultConnection"]);          
            string decryptedConnectionString = System.Text.ASCIIEncoding.ASCII.GetString(b);

http://www.codersource.net/2010/02/03/securing-connection-strings-in-asp-net/