C# Asp.Net Triple-Des
I have two aspx pages in a single project. For trial purposes these two pages are in a single project but in the future they will be on seperate servers.
There's a button on the first page (Default.aspx) and this is the code behind:
protected void btnSub_Click(object sender, EventArgs e)
{
var name = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
WebRequest req = null;
WebResponse rsp = null;
try
{
const string uri = "http://localhost:52958/WebSite1/Default2.aspx";
req = WebRequest.Create(uri);
req.Method = "POST";
req.ContentType = "text/xml";
var writer = new StreamWriter(req.GetRequestStream());
var post = "<VbDoc><Sicil>a</Sicil>,<AdSoyad>b</AdSoyad>,<SubeKodu>c</SubeKodu>,<SubeAdi>d</SubeAdi>,<Mail>e</Mail>,<Tel>f</Tel></VbDoc>";
post = Encrypt(post);
writer.Write(post);
writer.Close();
rsp = req.GetResponse();
}
catch
{
throw;
}
finally
{
if (req != null) req.GetRequestStream().Close();
if (rsp != null) rsp.GetResponseStream().Close();
}
}
On the second page (Default2.aspx) PageLoad gets activated when I debug and I can read the encrypted data but after page_load the page never gets visible, the old one stays. This is the page load of the second page.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.Response.IsRequestBeingRedirected)
{
Page.Response.ContentType = "text/xml";
var reader = new StreamReader(Page.Request.InputStream);
var xmlData = reader.ReadToEnd();
if (xmlData.Length != 0)
{
xmlData = Decrypt(xmlData);
TextBox1.Text = xmlData;
}
}
}
---If I use Response.Redirect on the first page the second page comes visible but I lose the encrypted data.
---My boss doesn't allow me to use query strings
How can I be able to read the response and show the second page.
Thanks in advance.
I Solved it with html post mechanism. .cs like:
protected void btnSub_Click(object sender, EventArgs e)
{
var post = "xml data";
post = Encrypt(post);
Label1.Text = post;
}
.aspx is like
<body>
<form id="form1" runat="server" >
<asp:Label Visible="False" ID="lblEncrypted" runat="server"></asp:Label>
</form>
</body>
<body>
<form name="tokenForm" method="POST" action="http://localhost:52958/WebSite1/Default2.aspx">
<input type="hidden" name ="token" value='<%=Label1.Text%>' />
<input type="submit" id="btnGonder" value="gonder"/>
</form>
</body>