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 41035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:07:02+00:00 2026-05-10T15:07:02+00:00

I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult

  • 0

I have an action like this:

public class News : System.Web.Mvc.Controller {     public ActionResult Archive(int year)     {        / *** /     } } 

With a route like this:

routes.MapRoute(            'News-Archive',                                                          'News.mvc/Archive/{year}',                                       new { controller = 'News', action = 'Archive' }        ); 

The URL that I am on is:

News.mvc/Archive/2008 

I have a form on this page like this:

<form>     <select name='year'>         <option value='2007'>2007</option>     </select> </form> 

Submitting the form should go to News.mvc/Archive/2007 if ‘2007’ is selected in the form.

This requires the form ‘action’ attribute to be ‘News.mvc/Archive’.

However, if I declare a form like this:

<form method='get' action='<%=Url.RouteUrl('News-Archive')%>'> 

it renders as:

<form method='get' action='/News.mvc/Archive/2008'> 

Can someone please let me know what I’m missing?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T15:07:02+00:00Added an answer on May 10, 2026 at 3:07 pm

    You have a couple problems, I think.

    First, your route doesn’t have a default value for ‘year’, so the URL ‘/News.mvc/Archive’ is actually not valid for routing purposes.

    Second, you’re expect form values to show up as route parameters, but that’s not how HTML works. If you use a plain form with a select and a submit, your URLs will end up having ‘?year=2007’ on the end of them. This is just how GET-method forms are designed to work in HTML.

    So you need to come to some conclusion about what’s important.

    • If you want the user to be able to select something from the dropdown and that changes the submission URL, then you’re going to have to use Javascript to achieve this (by intercepting the form submit and formulating the correct URL).
    • If you’re okay with /News.mvc/Archive?year=2007 as your URL, then you should remove the {year} designator from the route entirely. You can still leave the ‘int year’ parameter on your action, since form values will also populate action method parameters.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ASP.NET MVC I have a controller that looks somehow like this: public class
I have a action script from a decompile flash like this public function getResourceAsByteArray(resID:int):flash.utils.ByteArray
Hi, I have a action that looks like this : [AcceptVerbs(HttpVerbs.Post)] public ActionResult Register(AdRegister
I have a model, smth like this: class Action(models.Model): def can_be_applied(self, user): #whatever return
I have a class that looks like this: public class UserListVM { public SearchModel
Suppose I have a class like the following: public class Stage { public int
I've got an action with a signature like this: public ActionResult Index([ModelBinder(typeof(MyEnumModelBinder))] MyEnum myEnum)
I have a class hierarchy like this public abstract class CalendarEventBase{} public class TrainingEvent
Let's say I have two classes that look like this: public class ByteFilter {
Basically I have 2 classes, Manifest and BrowserAction, set out like this: public class

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.