0

I am using ASP.NET Web Forms. I am trying to bind some data from a previous page (including the URL and some specific figures stored in the URL) to session variables for use in a SQL insert statement to a SQL Server database.

An example of one of the assignments is below:

this.Session["URL"] = HttpUtility.ParseQueryString(Request.UrlReferrer.Query)["helpurl"];

The problem I am having is that on executing the SQL insert, the value does not seem to be present and the default value is recorded. SessionState is enabled. I am able to print the result of the HttpUtility method to a label, and I am also able to assign to session variables for a SQL statement if I assign them directly, eg:

this.session["Variable"] = Variable; 

Any ideas why the result of the HttpUtility function may not be assigned to the session variable prior to the execution of the SQL insert statement?

शेखर
  • 17,412
  • 13
  • 61
  • 117
Soluble Snake
  • 73
  • 1
  • 12

1 Answers1

0

It's ok - I placed the assignments inside an

if(!IsPostBack)

And they now work ok and are being recorded to the database. I also removed the 'this' keyword from them.

Thanks anyway

Soluble Snake
  • 73
  • 1
  • 12