-2

How is it possible to return a value in an ASP.NET web page? I need to return the value "1". I'm not sure how to do that. Is it as simple as writing 1 in the content of the .aspx file, or do I need to do anything else?

That's the request that is given:

GET /kartclient/kartlogin.aspx HTTP/1.1. Accept: text/*
John Saunders
  • 160,644
  • 26
  • 247
  • 397
user3717565
  • 33
  • 1
  • 7
  • `Response.Write("1")` – ElGavilan Jun 20 '14 at 17:39
  • What do you mean, "return a value"? Do you mean "return a response body containing a value"? – John Saunders Jun 20 '14 at 17:40
  • @ElGavilan One last question - how do I get the arguments that are included within the request? – user3717565 Jun 20 '14 at 17:43
  • You can get those by accessing the [HttpContext.Current](http://stackoverflow.com/questions/976613/get-post-data-in-c-asp-net) object. That is, assuming that you are talking about http posted values. – ElGavilan Jun 20 '14 at 17:47
  • Also (and again I am assuming that you just want to return a response body containing nothing else but "1") you might want to call `Response.End()` after writing the value. – ElGavilan Jun 20 '14 at 17:50
  • Once you "write" 1, what will you do with it? Is there another "web page" that will process the value 1? What is your objective? Right now its very hard to understand what you want to accomplish and why? – lucidgold Jun 20 '14 at 17:56

1 Answers1

1

Since kartlogin.aspx seems to be a user-login page, then are you interested in passing userID + password to another page?

Still not sure what you are trying to achieve, but if its only passing data from one page to another, there are many ways, here are some quick ones you can try:

On kartlogin.aspx:

1. Query String Method Send/Post Value:

string name="xyz";
Response.Redirect("Page2.aspx?name= "+name);

2. Cookie Method Send/Post Value:

HttpCookie myCookie = new HttpCookie("name");
myCookie.Value="xyz";
Response.Cookies.Add(myCookie);

3. Session Method Save Value:

Session["name"] = "xyz";

On Page2.aspx:

1. Query String Method Get Value:

string name = Response.QueryString.GetValue(" name ");
Response.Write(name);

2. Cookie Method Get Value:

string name = Request.Cookies('name');
Response.Write(name);

3. Session Method Get Value:

string name = Session["name"].ToString();
Response.Write(name);

You should take a look at:

Community
  • 1
  • 1
lucidgold
  • 4,432
  • 5
  • 31
  • 51