QUERY STRING
DIFFERENCE BETWEEN COOKIE
AND QUERY STRING
1. THERE IS AN LIMIT OF THE
BROWSER TO APPENED THE DATA, IN QUERY STRING WE APPEND OUR VALUES IN URL OF THE
BROWSER TO ACCESS IT ANOTHER PAGE
2. IN QUERY STRING WE CAN ACCESS THE VALUE AT THE SAME PAGE OR MAY BE AT
THE TARGET PAGE WHERE AS IN COOKIE WE CAN ACCESS THE DATA IN ANY PAGE
3. HERE ? (QUESTION MARK) IN URL
SEPERATING THE URL VALUE AND QUERY STRING VALUE AND &(AMPERCENT) SEPARATE
TWO OR MORE QUERY STRING VALUE
4. This technique is also not a secure. A client can do changes on the url
value send by the server at client side
ON DEFAULT. ASPX
public partial
class _Default
: System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
}
protected void
Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx?i=10");
Response.Redirect("Default2.aspx?id=" + TextBox1.Text + ",&name=" + TextBox2.Text + "");
}
}
ON SECOND PAGE DEFAULT2.ASPX
public partial
class Default2
: System.Web.UI.Pageres
{
protected void Page_Load(object
sender, EventArgs e)
{
string
s = Request.QueryString["i"];
Response.Write(s);
string
s = Request.QueryString["id"];
string
m = Request.QueryString["name"];
Response.Write(s + "," + m);
}
}
ON SAME PAGE
public partial
class _Default
: System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
if
(Request.QueryString["id"] != null && Request.QueryString["name"] != null)
{
string
s = Request.QueryString["id"];
string
m = Request.QueryString["name"];
Response.Write(s + "," + m);
}
}
protected void Button1_Click(object
sender, EventArgs e)
{
//Response.Redirect("Default2.aspx?i=10");
Response.Redirect("Default.aspx?id=" + TextBox1.Text + ",&name=" + TextBox2.Text + "");
}
}
No comments:
Post a Comment