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

  • Home
  • SEARCH
  • 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 727021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:31:10+00:00 2026-05-14T06:31:10+00:00

Using ASP MVC, I have set up a webpage for localhost/Dinner/100 to show the

  • 0

Using ASP MVC, I have set up a webpage for localhost/Dinner/100 to show the dinner details for dinner with ID = 100.

On the page, there is a dropdown that shows Dinner 1, Dinner 2, etc. The user should select the dinner of interest (Dinner 2, ID = 102) off the form and press submit. The page should refresh and show the url: localhost/Dinner/102, and show the details of dinner 2.

My code is working except for the url. During this, my url shows localhost/Dinner/100 even though it is correctly displaying the details of Dinner 2 (ID = 102).

My controller method is pretty simple:

    public ActionResult Index(string id)
    {
        int Id = 0;
        if (!IsValidFacilityId(id) || !int.TryParse(id, out Id))
        {
            return Redirect("/");
        }

        return View(CreateViewModel(Id));
    }

can you help me figure out how to get this all working?

p.s. I did create a custom route for the method:

routes.MapRoute(
            "DinnerDefault",                         // Route name
            "Dinner/{id}",                           // URL with parameters
            new { controller = "Dinner", action = "Index", id = "" }  // Parameter defaults
        );
  • 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-14T06:31:10+00:00Added an answer on May 14, 2026 at 6:31 am

    If you are using ASP.NET MVC HtmlHelper BeginForm() method, keep in mind that by dafult it uses the POST method.

    I Think the easiest way is to do this via RedirectToAction result.

    View:

    <body>
        <% Html.BeginForm("Select", "Home"); %>
                <select id="dinners" name="dinners">
                    <option value="100">dinner 1</option>
                    <option value="101">dinner 2</option>
                    <option value="102">dinner 3</option>
                </select>
                <button type="submit"></button>
        <% Html.EndForm(); %>
    </body>
    

    Controller:

        public ActionResult Index(string id)
        {
            int Id = 0;
            if (!IsValidFacilityId(id) || !int.TryParse(id, out Id))
            {
            return Redirect("/");
            }
    
            return View(CreateViewModel(Id));
    
        }
    
        public ActionResult Select(string dinners)
        {
            return RedirectToAction("Index", "Home", new {id = dinners});
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.NET MVC RC2. I have a set of classes that were auto-generated
I am using asp.net MVC to develop an application that will have ajax interactions.
I have an ASP.NET MVC (Beta 1) website that I'm using themes with. When
Using ASP.NET MVC there are situations (such as form submission) that may require a
I'm making an webpage using ASP.NET MVC. I have the following input hidden definied:
Im using asp.net mvc 2. I have a model Supermodel that consists of 2
I am in the start up of a project using ASP.NET MVC and have
I am currently creating an e-commerce site using C# ASP.NET MVC and have just
I've been developing a site using ASP.NET MVC, and have decided to use the
I’ve only just started using ASP.NET MVC, and I have a somewhat trivial question:

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.