0

i have the problem of retrieving the querystring and verifying the email in mvc3 application. The thing i want to do is get the querystring values and pass it to a method to execute but when i retrieve the value from the controller the querystring is having the value but when i take a variable and assign the querystring value to it, then it is showing null value. why is this?

This is my controller code

    public ActionResult LogOn()
    {

        if (HttpContext.Request.QueryString["EmailId"] != string.Empty)
        {
            var q = Request.QueryString["EmailId"];
            userMgr = new UserManager();

            MyDoctor.Models.DocUser user = userMgr.GetByEmailForExistUser(Request.QueryString["EmailId"]);
            try
            {
                user.Status = true;
                user.UpdatedDate = System.DateTime.Now;
                userMgr.Update(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        return View();
    }

1 Answer 1

2

Because it is null :)

You might need to change your if statement to something like this:

if( !string.IsNullOrEmpty( HttpContext.Request.QueryString["EmailId"] ) )
Sign up to request clarification or add additional context in comments.

Comments

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.