Diver Dan
Diver Dan

Reputation: 9963

read query stringfrom mvc url

This maybe a stupid question but i've come from an asp.net background so reading a querystring is pretty easy, not to sure how I should be doing it with mvc.

Lets say I have a url that looks like https://localhost/Account/Verify?code=3ae9a4f4-84d3-4686-b5a6-3e53e008537b

How do I read the code=3ae9a...........?

Upvotes: 1

Views: 1027

Answers (2)

buda
buda

Reputation: 2372

You can do it very simple.

string codeValue = "";
if(Request.QueryString["code"] != null)
{
    codevalue = Request.QueryString["code"]
}

And if you use Guid, like in this case, just create new Guid from value.

Upvotes: 2

Mohammed Swillam
Mohammed Swillam

Reputation: 9242

Request.QueryString["CODE"]

That's it :)

Upvotes: 2

Related Questions