.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

parameter in the browser address bar. How can I prevent this ?

Posted By: Shashi Ray     Posted Date: November 23, 2008    Points:2   Category :C#
Response.Redirect("Welcome.aspx?userfname=" & Session("UserFullName"))

The above will show value of "username" parameter in the browser address bar. How can I prevent this ?

Responses
Author: Pankaj Mishra             
Posted Date: November 23, 2008     Points: 5   

Hi,
I suggest you to encrypt the username and pass via QueryString. But if you are using Session then why do you want to pass via QueryString you can directly use session in your Welcome.aspx page.

Let me know if i understood wrong.

Cheers
pankaj

Author: Akhil Raj       [Moderator]      
Posted Date: November 26, 2008     Points: 5   

hi mate pankak mishra is right. You can simply do using session know..

But otherway i think you can use url rewriting for this. sorry if i am wrongly understand... If correct, you can heck the following article..


http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx


Author: Athira Sreejith             
Posted Date: April 08, 2009     Points: 5   

Hi..

You can try with Encrysption decrysption mechanisam:

.cs File:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Security.Cryptography;
using System.Xml;
using System.Text;
using System.IO;

/// <summary>
/// Summary description for Encryption
/// </summary>
public class Encryption
{
private static byte[] key = { };
private static byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
private static string EncryptionKey = "!5623a#de";

public Encryption()
{
}

/// <summary>
/// Decrypt Querstring Value
/// </summary>
/// <param name="Input"></param>
/// <returns></returns>
public static string Decrypt(string Input)
{
Byte[] inputByteArray = new Byte[Input.Length];
try
{
key = System.Text.Encoding.UTF8.GetBytes(EncryptionKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(Input);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();

Encoding encoding = Encoding.UTF8;
return encoding.GetString(ms.ToArray());

}
catch (Exception ex)
{
return "";
}

}

/// <summary>
/// Encrypt QueryString Value
/// </summary>
/// <param name="Input"></param>
/// <returns></returns>
public static string Encrypt(string Input)
{
try
{
key = System.Text.Encoding.UTF8.GetBytes(EncryptionKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
Byte[] inputByteArray = Encoding.UTF8.GetBytes(Input);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch (Exception ex)
{
return "";
}
}
}

Use:
Response.Redirect("AddClub.aspx?ClubId=" + Encryption.Encrypt(RowId));
string RowId = Encryption.Decrypt(Request.QueryString["ClubId"].Trim());



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend