开发者

mvc3 request.querystring throws null error

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();
    }


Because it is null :)

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

if( !string.IsNullOrEmpty( HttpContext.Request.QueryString["EmailId"] ) )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜