I'm trying to make an IHttpModule to change the response sent to the client, changing the query string with "id=", but I was unable to use Regex.Replace successfully.
I've this:
public override void Write(byte[] buffer, int offset, int count)
{
string bufferContent = UTF8Encoding.UTF8.GetString(buffer);
bufferContent = Regex.Replace(
bufferContent,
@"?id=(.*?)\",
m => string.Format("id={0}", CryptoLibrary.Encrypt(m.Groups[0].Value, BeGamer.ENCRYPTION_KEY))
);
outputStream.Write(UTF8Encoding.UTF8.GetBytes(bufferContent), offset, UTF8Encoding.UTF8.GetByteCount(bufferContent));
base.Write(buffer, offset, count);
}
CryptoLibrary.Encrypt(m.Groups[0].Value, BeGamer.ENCRYPTION_KEY) this is a class for encoding a number into a long string, so I get the id value em sent it there and after replace the original value for the encoded one.
Go to the complete details ...