D
D
Dmitry2016-11-28 17:53:33
ASP.NET
Dmitry, 2016-11-28 17:53:33

How to register routing in asp.net mvc4?

Good afternoon,
I have a similar situation...
A person registers on the site... that is, he filled out the registration form and upon successful registration, when he clicks on the button, he should go to the page located in Areas
How can I make a link?

[HttpPost]
        public ActionResult Register(Account account)
        {
            if (ModelState.IsValid)
            {
                using (RWODb db = new RWODb())
                {
                    db.Account.Add(account);
                    db.SaveChanges();
                }
                ModelState.Clear();
                return RedirectToAction("~/Areas/Admin/Views/Home/Index.cshtml");
            }
            return View();
        }

and my browser writes an error on pressing the button and following the link (the button code was made above)
But at the same time, registration in the database passes.
Here is a screenshot of the error in the browser:
c42a50a276f148ac94239e672caef3ad.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-11-28
@vip1987

Replace RedirectToAction with just Redirect("~/Admin/Home") or properly set RedirectToAction("Index", "Home", new {area = "Admin"});

D
Dmitry, 2016-11-28
@vip1987

Thanks Sergey.
I'll try it now and report back...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question