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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:09:07+00:00 2026-05-13T06:09:07+00:00

MVC encourages RESTful URL’s, yet HTML forms by nature append the data in query

  • 0

MVC encourages RESTful URL’s, yet HTML forms by nature append the data in query string values. My action takes “text” as a string parameter. And my form is:

<% using(Html.BeginForm("Action", "Controller")) { %>
  <%= Html.TextBox("text") %>
  <input type="submit" value="submit" />
<% } %>

My action is:

public ActionResult Action(string text)
{
    ...
    return toInnocence;
}

There are two distinct URL’s that your action can map to:

  1. ~/Controller/Action/textvalue thanks to your route map {controller}/{action}/{text}
  2. ~/Controller/Action?text=textvalue when submitted from a form

My question is:

How can I differentiate between two forms and do a redirect in the latter case? The second form breaks RESTful principle. What’s the best practice there? I don’t want to query RouteData.Values collection because it breaks the whole purpose of mapping request parameters to function arguments in a natural, straightforward way. This is a very basic scenario I expect MVC to handle this nicely.

The second form doesn’t map to “text” parameter in the controller action. Why? How can I create overloaded versions of the same action then? Do I have to create a new action and use it for form submissions? Of course I can workaround all these but at the same time I’m afraid of missing the big picture somewhere.

It looks like people are getting along with these at ease so I feel like I’m the only one who is confused by route values against query strings.

EDIT: I looked at how Wikipedia does this. It uses separate actions for “form getter” and the actual restful URL and redirects from one to another as needed. I guess that would be the best way of doing it.

  • 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-13T06:09:08+00:00Added an answer on May 13, 2026 at 6:09 am

    The default operation of your browser is to put the values in the GET form in the query string. They will both resolve to a route of and go to the same action.

    { controller = "Controller", "Action", id = null, text = "textvalue" }
    

    Because of the presence of the default route, this will correctly resolve.

    The only way I can think of to do what you’re asking is to change the form. Instead of submitting a “GET” request, submit as a PUT because you don’t need a POST (you can do this with JS, with a friendly degrade to POST) and redirect to a GET.

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

Sidebar

Related Questions

MVC Controller Action 1 : Displays values on a view page. MVC Controller Action
MVC use action attributes to map the same view for http get or post:
MVC isn't generating the client-side validation rules for my viewmodel. The HTML just contains
MVC 2 I'm trying to post to an MVC action using jQuery, but I'm
My MVC application has a simple file download controller action that downloads a file.
MVC is very clear on how data is sent to the browser. You go
Does MVC 3 support Xml data? I have a model class with a field
MVC @Html.TextBoxFor(model => model.SomeNotNullableType) When using this helper, if I have a type that
MVC 3. VB.NET I have the following controller action in my application to send
MVC Newbie here. I want to get User confirmation before controller action (update a

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.