dimanche 1 mai 2016

MVC ReturnUrl link error

I'm working on ReturnUrl in mvc but i have some url link error.

a href="/User/Login?returnurl=/Forum/Detail/@item.ID" with this link going to Login view and carrying returnurl parameters.

In the login page i catch returnurl querystring with this code

string url = Request.QueryString["returnurl"];

        if (ModelState.IsValid)
            if (db.Users.Any(x => x.Mail == model.EMail && x.Password == model.Password && x.IsDelete == false))
                FormsAuthentication.SetAuthCookie(model.EMail, true);

                if (!string.IsNullOrEmpty(url))
                    return RedirectToAction(url);
                return RedirectToAction("Index", "Home");

After when i click sign in i cannot go back to my first url. Link turn this http://localhost:61476/User/Forum/Detail/3

I want to turn back this url: http://localhost:61476/Forum/Detail/3

Aucun commentaire:

Enregistrer un commentaire