1

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...........?

2 Answers 2

2
Request.QueryString["CODE"]

That's it :)

Sign up to request clarification or add additional context in comments.

Comments

2

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.

3 Comments

buda, sorry but this is a TOO COMPLICATED ANSWER for such simple question :)
Probably, but what if value does not exists, application crashes. :)
from a quality prespective, YES. but note that he is only asking for the way to read it :) BTW, I like people who care about handling exceptions early. +1 for that :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.