Reputation: 803
I have a javascript variable in a page default.aspx
var name="user1"
window.location="test.aspx"
this page will submit to test.aspx and in global.asax while firing Application_BeginRequest event ,i need to access the variable "name". i need to do this without cookies. Anyone can help me on this?
Upvotes: 0
Views: 911
Reputation: 35409
If by "submit" you mean perform a POST
or GET
request then you'll need to pass name
as a url-encoded
string to the server as a form POST
or as a querystring parameter in a GET
request.
Then, in the Application_BeginRequest
access the Request
from the Current
HttpContext
Upvotes: 1
Reputation: 1038930
var name="user1"
is a javascript variable that you could access inside Application_BeginRequest
from the Request object assuming you have passed it to the test.aspx
page when redirecting:
var name = "user1";
window.location.href = 'test.aspx?name=' + encodeURIComponent(name);
and then:
protected void Application_BeginRequest(object sender, EventArgs e)
{
string name = HttpContext.Current.Request["name"];
if (!string.IsNullOrEmpty(name))
{
// the name variable was present in the request => do something with it
}
}
Upvotes: 1