Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7693337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:03:57+00:00 2026-05-31T21:03:57+00:00

I have a ASP.NET MVC 3 app with a common scenario where there is

  • 0

I have a ASP.NET MVC 3 app with a common scenario where there is with an “About” controller using “Contact” and “ThankYou” actions.
I want user to go to /about/contact, fill out the form, submit it, and be taken to /about/contact/thankyou * page where the form contents (aka view model) will be displayed.

** Note there is no “Contact” controller nor do I want to create one for this purpose if possible.*

I am using RedirectToAction to prevent resubmission (Post/Redirect/Get pattern) and TempData to pass on view model to thank you page.
I can also use TempData to check if thank you page was reached directly and redirect back to contact form page (so it would not register as a “goal” in web analytics)

But one thing I could not figure out is how to use different route for thank you page so it appears as /about/contact/thankyou

Am I doing this right?
Is there a better way?

Here are relevant actions in AboutController

<!-- language: c# -->
[RequireHttps]
public ActionResult Contact()
{
    var viewModel = new ContactViewModel();
    return View(viewModel);
}
[RequireHttps]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Contact(ContactViewModel viewModel)
{
    if (!ModelState.IsValid)
    {
        return View(viewModel);
    }       
    // not sure if this is the best way or how to redirect to /contact/thankyou 
    TempData["viewModel"] = viewModel;
    return RedirectToAction("ThankYou");
}               

[RequireHttps]
public ActionResult ThankYou()
{
    var viewModel = TempData["viewModel"];
    // upon direct access, viewModel will be null and missing, so redirect to Contact form
    if (viewModel == null)
    {
        return RedirectToAction("Contact");
    }
    return View(viewModel);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:03:58+00:00Added an answer on May 31, 2026 at 9:03 pm

    You could define a custom route before the default route:

    routes.MapRoute(
        "contact",
        "about/contact/thankyou",
        new { controller = "About", action = "ThankYou" }
    );
    

    Now when you navigate to /about/contact the Contact GET action will be executed (You have to rename it as in your code it is called ContactUs). Then the user fills the form and submits to the Contact POST action. The url stays the same for the moment: /about/contact. After the redirect the ThankYou action is executed and the url changes to /about/contact/thankyou.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam using .NET 3.5. I have asp.net mvc app. There is base controller: public
I have an ASP.NET MVC app and I want to add to each page
I have an ASP.Net-MVC app using LinqToSql. I have a subcontracts table, a service_lines
I have an asp.net mvc app, using JQuery UI dialog. I'm trying to submit
I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything
I have an asp.net MVC App that I want to deploy to IIS 5
I have an ASP.NET MVC app and am using Forms auth. When going to
In my ASP.net MVC App (using Razor views) I have a ProductDetails view. This
I have a ASP.NET MVC 4 app. I want to copy a text(from PDF)
So, I have an asp.net mvc app that is being worked on by multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.