Hello Everyone,
There is one problem regarding Page Redirection. Here is Sample code
1) Database Connection -> Done
2) Insert Data -> Done
3) Add value inside Session variable -> Done
4) Redirect to success page -> Problem come up Here :(
Default1.aspx:
......
Dim success As String = "Success"
......
Try
sqlCom.ExecuteNonQuery()
sqlCon.Close()
Session("success") = success
MsgBox(Session("success")
modifyXmlData(filePath);
Response.Redirect("default2.aspx", False)
Catch ex As Exception
MsgBox("Exception" + ex.Message)
End Try
End Sub
Protected Sub modifyXmlData(ByVal filepath As String)
Dim strPath = Server.MapPath(filepath)
Dim xmlFile = XDocument.Load(strPath)
xmlFile.<root>.<ListItem>.Where(Function(f) _
f.@value = ddl_SelectedValue).@visited = "Yes"
xmlFile.Save(strPath)
End Sub
defualt2.aspx
inside page_Load()
Dim success As String = Session("success").toString
MsgBox(success)
End Sub
1st Approach : Using Response
It Redirects to next Page properly but when I am trying to get Session value
It Shows Empty always..
2nd Approach : Using Server
I am afraid with this option, because It holds the session value and at the time of redirection it executes the Page_Load event of Default2.aspx but after page_load Control get destroyed and stays on my Default1.aspx (first page)
instead of Server.Execute I used Server.Transfer but it raise the Exception -" thread is being aborted"
Thanking you
Please show me way to rectify this problem