-3

I have been trying to find the question to my answer but I'm unable to and finally I'm here. What I want to do is access the value passed to a webpage (GET, POST request) using asp.net. To be more clear, for example:

URL: http://www.foobar.com/SaleVoucher.aspx?sr=34

Using asp.net I want to get the sr value i.e 34.

I'm from the background of C# and new to ASP.NET and don't know much about ASP.NET.

Thanx.

Kamran Ahmed
  • 11,809
  • 23
  • 69
  • 101

2 Answers2

1

Can you refer to this QueryString

Here he says how to access the query string using:

Request.Url.Query
Community
  • 1
  • 1
RONE
  • 5,415
  • 9
  • 42
  • 71
0

That is not called a Header, but the Query String.

the object document.location.search will contain that and the javascript to get any query string value based on the key would be something like:

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

code from other question: https://stackoverflow.com/a/901144/28004

Community
  • 1
  • 1
balexandre
  • 73,608
  • 45
  • 233
  • 342