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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:02:35+00:00 2026-06-12T19:02:35+00:00

I noticed that doing @Url.Action(myAction, new { param1 = 123, param2 = 456}) provides

  • 0

I noticed that doing @Url.Action("myAction", new { param1 = 123, param2 = 456}) provides me with an invalid URL Home/myAction?param1=123&param2=456.

I am attempting to do

$("#myAjaxDiv").load(url);

But only param1 is getting populated in the action method.

When I remove the & and make it just & then it works, but doing a string replace is super hacky.

url = url.replace("&", "&");

Am I missing something here?

EDIT: Per request I’m including some of my sample app. (you can create a new MVC app and just add these quickly and see for yourself)

Controller:

public ActionResult AjaxTest(int? year, int? month)
{
    ViewBag.Message = string.Format("Year: {0}, Month: {1}", year.HasValue ? year.ToString() : "no year", month.HasValue ? month.ToString() : "no month");
    return PartialView("AjaxTest");
}

AjaxTest View:

@ViewBag.Message

Index View:

<script>
    $(function () {
        var url="";
        $("#noParams").click(function () {
            url = "Home/AjaxTest";
            $("#ajaxy").load(url)
            $("#url").text(url);
        });
        $("#yearParam").click(function () {
            url = "Home/AjaxTest?year=2012";
            $("#ajaxy").load(url)
            $("#url").text(url);
        });
        $("#yearAndMonthParam").click(function () {
            url = "Home/AjaxTest?year=2012&month=10";
            $("#ajaxy").load(url)
            $("#url").text(url);
        });

        $("#generated").click(function () {
            url = "@(Url.Action("AjaxTest", new { year=2012, month=10}))";
            $("#ajaxy").load(url);
            $("#url").text(url);
        });

    });
</script>

<a id="noParams" href="#">No Params</a> <br />
<a id="yearParam" href="#">Year Param</a> <br />
<a id="yearAndMonthParam" href="#">Year and Month Param</a> <br />
<a id="generated" href="#">Generated</a> <br />
<div id="ajaxy">

</div>

<div>
URL: <span  id="url"></span>
</div>
  • 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-06-12T19:02:36+00:00Added an answer on June 12, 2026 at 7:02 pm

    By default every content (which is not IHtmlString) emitted using a @ block is automatically HTML encoded by Razor (see this Razor intro article Html Encoding section)

    The Url.Action returns just a plain string so thats why the & gets encoded.

    Use the Html.Raw if you don’t want the encodeing:

    url = "@(Html.Raw(Url.Action("AjaxTest", new { year=2012, month=10})))";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have noticed that doing actions like implementing an interface, that a small rectangle
While doing some experiment on serialization, I noticed that my object name is lost
I'm working on a database program and I noticed that when I'm doing queries
I have noticed that many websites use urls that end in website.com/index.php?var=value&var2=value2 and I
I noticed today that there is a new version of Aptana Studio 3.2.1 out
I have been doing some mobile web app testing and have noticed that the
I am doing some exercises in my object-oriented javascript book, I notice that this:
I notice a strange thing during doing some stored procedures I can explain that
I noticed that the <td align=center> code works differently on the MediaWiki.org page and
I noticed that there are two sets of Hadoop configuration parameters: one with mapred.*

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.