0

URL: http://localhost:11111/foldername/pagename.aspx#&&PORS=reactive&GridSortDirection=Ascending&GridPage=0&CJ=false&GridSortExpression=SiteReference&CN=na na

Variable in Question : CN with value na na

When I try below code I am getting null reference exception

string test = Request.QueryString["CN"].ToString();

Am I missing anything?

Note: in the above URL I have tried all variables such as PORS, GridSortDirection etc none of them are working.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Hakan Zim
  • 305
  • 1
  • 5
  • 15
  • Querystring is the content after the '?' in the URL. You have '#' instead of '?'. '#' is used to jump to the anchor on the same page. URL should be like: http://localhost:11111/foldername/pagename.aspx?PORS=reactive&GridSortDirection=Ascending&GridPage=0&CJ=false&GridSortExpression=SiteReference&CN=na na – PratikDotCa Aug 14 '14 at 15:29

2 Answers2

0

Querystring is the content after the '?' in the URL. You have '#' instead of '?'. '#' is used to jump to the anchor on the same page.

URL should be like:

URL= http://localhost:11111/foldername/pagename.aspx?PORS=reactive&GridSortDirection=Ascending&GridPage=0&CJ=false&GridSortExpression=SiteReference&CN=na na
PratikDotCa
  • 164
  • 11
  • thanks for pointing out its an anchor mark , i can only resolve it through javascript see the link for more information http://stackoverflow.com/questions/1322108/c-sharp-get-complete-url-with – Hakan Zim Aug 14 '14 at 15:39
  • sorry, I couldn't get. The URL in your question does not have '?', so are those anchors in your URL? – PratikDotCa Aug 14 '14 at 15:45
  • that's fine but the anchors are there for a reason, i cannot change the way URL is built just wanted to extract the values, but apparently i cannot from the code behind, see the URL i posted – Hakan Zim Aug 14 '14 at 16:04
0

Your URL contains a Page Fragment Identifier (#). The browser does not send anything to the right of the # back to the server (including the # itself). So there is no way for the server to make use of that information, unless you do something nonstandard like send it via an ajax call with javascript.

Aheho
  • 12,622
  • 13
  • 54
  • 83