c# - Getting the value from cookie and storing in the database -
I want to store the search URL in the form of a cookie on the client side and write back this url in the database . No error is showing, but it has not written the URL string in the database. I have personally tested the URL in the database, it works fine. Just when I was trying to work with the cookie, not working. Please tell me if you have any suggestions
// JavaScript part
location.href = "& lt;% = UU.RTOSTRING ()%>?" + Math.random () + "#" + query.toString ();
document.cookie = "kursearch =" + query.toString ();
// # code
Storetxt (text); } Public string GetCookie (string cookies) {string cookyval = ""; Try {cookyval = request Cookies [Cucunema]. value; } Hold (exception e) {cookyval = ""; } Return cookie; } Public Zero Startext (String Text) {string connection = "Data Source =. \\ SQLEXPRESS; Initial Catalog = PtsKuratlas; Integrated Security = True"; SqlConnection conn = faucet; SqlCommand CMD = Faucet; Try {conn = new SqlConnection (connection); CMD = New SQL Commands ("Include GTANETics (keyword) values (@ link)", Kon); Cmd.CommandType = CommandType.Text; Cmd.Parameters.AddWithValue ("@ link", txt); Conn.Open (); Cmd.ExecuteNonQuery (); } Hold (Exception Pre) {} Finally {if (cmd! = Null) cmd.Dispose (); If (conn! = Null) {if (conn.State == ConnectionState.Open) conn.Close (); Conn.Dispose (); }}}}
Why are not you setting cookies before server calls ?
Comments
Post a Comment