0

I have this URL

var url = "/test/Create/" + $("#hdnFlag").val() +"?CmpT="+"Ilim";
window.location.href = url;

and in my Test controller I do this to get query string value

 tM_PMO.Type = Request.QueryString["CmpT"];

But always give me null values.

Heretic Monkey
  • 10,498
  • 6
  • 45
  • 102

1 Answers1

-1

I hope you are looking for below code sample where we just fetch the value in url which we says query string:

Request.QueryString["querystringparamname"].ToString(); 

You can assign this in any Var and use accordingly.

Aswal
  • 302
  • 2
  • 6
  • Is it something wrong with the answer, i just replied becuase question was not clear that's i made this reply as seeing the question. – Aswal Jun 18 '20 at 18:17
  • I didn't downvote your answer but I guess if OP is getting null value and you add a `.ToString()` by the end, it's going to raise an error [NullReferenceException](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it/4660186). Cannot call a method on a null reference object. – Daniel Manta Jul 22 '20 at 00:23