i have created two aspx pages for the demo,
page1 - WebForm1.aspx
<asp:TextBox ID="txtTest" runat="server" Width="100px"></asp:TextBox>
<asp:Button ID="btnClick" runat="server" Text="test" Width="100px" OnClick="btnClick_Click"/>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["text"] == null || string.IsNullOrEmpty(Request.QueryString["text"].ToString()))
txtTest.Text = "ö";
else
txtTest.Text = Request.QueryString["text"].ToString();
}
}
public void btnClick_Click(object sender, EventArgs e)
{
HttpResponse response = HttpContext.Current.Response;
response.Write(string.Format("<script>window.location = '{0}';</script>", HttpUtility.JavaScriptStringEncode("WebForm2.aspx?text=" + HttpUtility.UrlEncode(txtTest.Text))));
response.End();
}
page2 - WebForm2.aspx
<asp:TextBox ID="txtResult" runat="server" Width="200px"></asp:TextBox>
<asp:Button ID="btnBack" runat="server" Text="back" Width="50px" OnClick="btnBack_Click"/>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["text"] == null || string.IsNullOrEmpty(Request.QueryString["text"].ToString()))
txtResult.Text = "empty";
else
txtResult.Text = Request.QueryString["text"].ToString();
}
}
public void btnBack_Click(object sender, EventArgs e)
{
HttpResponse response = HttpContext.Current.Response;
response.Write(string.Format("<script>window.location = '{0}';</script>", HttpUtility.JavaScriptStringEncode("WebForm1.aspx?text=" + HttpUtility.UrlEncode(txtResult.Text))));
response.End();
}
and then i used Fiddler to track the web, clicked test button and then clicked back button.
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom
6 200 HTTP localhost:56484 /WebForm2.aspx?text=%c3%b6 835 private text/html; charset=utf-8 iexplore:12316
8 200 HTTP localhost:56484 /WebForm2.aspx?text=%u00f6 175 private text/html; charset=utf-8 iexplore:12316
9 200 HTTP localhost:56484 /WebForm1.aspx?text=%c3%b6 830 private text/html; charset=utf-8 iexplore:12316
10 200 HTTP localhost:56484 /WebForm1.aspx?text=%u00f6 175 private text/html; charset=utf-8 iexplore:12316
11 200 HTTP localhost:56484 /WebForm2.aspx?text=%c3%b6 834 private text/html; charset=utf-8 iexplore:12316
we could see the URL bodies have strange encoding, why did %u00f6 generate? can it be back to %c3%b6?
and when we were clicking back button to back to page1, its referrer became missing. Actually i think the strange encoding caused the issue, because when i used F12 Developer tools to change the action(from "%u00f6" to "%c3%b6"), and then clicked back button, the referrer was generated.
click here to see the screenshot
much appreciate to you if you can give the answer.