Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Variable changes value by another user

$
0
0

I have a file map.aspx which uses querystring to identify which user is which on the map so the first person uses map.aspx?mac=11111 for example.
In map.aspx.cs I have this code to define and initiate the variable.

public partial class map : System.Web.UI.Page
{
   ...
   public static string mac = HttpContext.Current.Request.QueryString["mac"] == null ? "" : HttpContext.Current.Request.QueryString["mac"];
   ...
}

And on map.aspx there is a jquery ajax that updates the map and it calls the function on map.aspx.cs in intervalls:

[System.Web.Services.WebMethod]
public static string getLocation()
{
   ...
 lots of code and I send mac to the map so I can see the value
   ...
}

where I use the variable mac in a sql string
finally I have this code in Page_Load:

protected void Page_Load(object sender, EventArgs e)
{
 mac = Request.QueryString["mac"] == null ? "" : Request.QueryString["mac"];
   ...
}

Everything works in browser 1 until I open browser 2 to simulate another user with map.aspx?mac=22222.
Now on the first browser the mac changes from 11111 to 22222? How is that possible?
If I update browser 1, the second browser gets the wrong value (both gets 11111).

If I change the initial code from
public static string mac = HttpContext.Current.Request.QueryString["mac"] == null ? "" : HttpContext.Current.Request.QueryString["mac"];
to
public static string mac;

then both gets the 11111 value (if I open ?=11111 first)

This is also tested on 2 different mobile phones with same result.

What is the solution?

p.s. can´t get this wysiwyg to work with the "insert code" thingy.


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>