0

I have a controller that creates a news article. I want to redirect the user to the article's page, something like: "/article/1". Normally I could just throw in return View("MyAction") but I need to pass the integer along in this case. There are overloads for adding a model to the View method call but I don't see anything that will let me accomplish my goal.

What's the best way to do this?

Also, I used ViewData for my success message... if I use a redirect message it isn't going to function so is there a better way to do that too?

1 Answer 1

1

I think this is what you might be looking for.

RedirectToAction(new {controller="controllerName", action="article", id=1});

Hope this helps

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

1 Comment

it actually looks like this:return RedirectToAction("Article", new { id = newAnnouncement.AnnouncementId }); but thanks for pointing me in the right direction!

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.