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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:16:57+00:00 2026-05-27T02:16:57+00:00

I am tring to pass a RouteValueDictionary to my aspx so that I can

  • 0

I am tring to pass a RouteValueDictionary to my aspx so that I can use it as the parameters for an Ajax.BeginForm method. I load it up like so:

 RouteValues = new System.Web.Routing.RouteValueDictionary();

 RouteValues.Add("FindingId", thisFinding.Id);
 RouteValues.Add("ReportId", thisFinding.ReportSection.ReportId);

and then add it to my model without issue. When I put it as the parameter to the BeginForm method it renders the action as this:

/SolidWaste/Finding/LoadSection?Count=3&Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D

Here is the aspx code:

(Ajax.BeginForm(Model.FormModel.Action,
    Model.FormModel.Controller, 
    Model.FormModel.RouteValues,
new AjaxOptions {
    HttpMethod = "Post",
    InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace,
    UpdateTargetId = "WindowContent",
}, new { id = FormId })) { %>
<input name="submit" type="submit" class="button" value="" style="float: right;"/>
<%  } //End Form %>

Here is the View Model that represents Model.FormModel

    public class FormViewModel {

    public string Action { get; set; }

    public string Controller { get; set; }

    public string Method { get; set; }

    public RouteValueDictionary RouteValues { get; set; }
}

Any idea why it is not serializing the RouteValueDictionary into the proper URL on the action? I would like to use an object here rather than build the RouteValues by hand with new { field = vale }

  • 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-27T02:16:58+00:00Added an answer on May 27, 2026 at 2:16 am

    Ah, you are using the wrong overload. It’s normal. The ASP.NET MVC team really made a mess out of this API. You gotta be careful which method you are invoking. Here’s the overload that you need:

    <% using (Ajax.BeginForm(
        Model.FormModel.Action,                                // actionName
        Model.FormModel.Controller,                            // controllerName
        Model.FormModel.RouteValues,                           // routeValues
        new AjaxOptions {                                      // ajaxOptions
            HttpMethod = "Post",
            InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace,
            UpdateTargetId = "WindowContent",
        }, 
        new Dictionary<string, object> { { "id", FormId } })    // htmlAttributes
    ) { %>
        <input name="submit" type="submit" class="button" value="" style="float: right;"/>
    <% } %>
    

    Notice the correct overload? You were using the one that was taking routeValues and htmlAttributes as anonymous objects, except that you was passing Model.FormModel.RouteValues as a RouteValueDictionary which basically crapped your overload.

    Hit F12 while hovering the cursor over the BeginForm and if you are lucky enough and Intellisense works fine for you in Razor views (which rarely happens) you will get redirected to the method you are actually invoking and realize your mistake.

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

Sidebar

Related Questions

When trying to pass a table built with HTML in my servlet like that:
I am trying pass an enum into a method, iterate over that enums values,
I am tring to setup a remote mysql user that can access mysql from
So I am trying pass in parameters to my buttonClicked function so that I
I'm trying to pass parameters from HTML-land to Flex-3 Flash-land, and can't seem to
im trying to pass some parameters from my a4j:mediaOutput to my bean. I can
im trying to pass two parameters to a function, i being an int value
When trying to pass a CGPoint to a method the point is passed, but
Trying to pass the variable flickrurl to a PHP page with jQuery/ajax. It works
im trying to pass new query to FlexiGrid using this code: $('#fgAllPatients').flexReload({ query: 'blah=qweqweqwe'

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.