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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:54:12+00:00 2026-06-14T05:54:12+00:00

How can I make my controller action to accept email as a param. These

  • 0

How can I make my controller action to accept email as a param.

These are the routes I have

routes.MapRoute(
                name: "infoNewsletterSignup",
                url: "info/SubscribeToNewsLetter/{email}",
                defaults: new { controller = "Info", action = "SubscribeToNewsLetter", email =UrlParameter.Optional});

            routes.MapRoute(
              name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Info", action = "Index", id = UrlParameter.Optional }
            );

This is my controller.

[HttpPost]
public string SubscribeToNewsLetter(string email)
{
   return "Thanks!\n\nYou have successfully subscribed for our newsletter.";
}

And this is my view

<td>
<input type="text" class="text-bx-foot" value="" id='newsLetterEmail' name='newsLetterEmail'></td>
<td>
<input name="Go" type="button" class="go-btn" value="Go" id="btnSubscribeToNewsLetters"></td>

$(document).ready(function () {
$("#btnSubscribeToNewsLetters").click(subscribeToNewsLetters);
});

function subscribeToNewsLetters() {
var objInputEmail = $("#newsLetterEmail");
if (objInputEmail != null) {
    var id = objInputEmail.val();
    if (id != null) {
        $.ajax({
            type: 'POST',
            url: '/Info/SubscribeToNewsLetter/' + id,
            //data: $('#form').serialize(),
            contentType: "application/json; charset=utf-8",
            traditional: true,
            success: subscribed,
            error: errorInSubscribing
        });
    }
}
}

function subscribed(data, textStatus, xhr) {
alert(data);
}

function errorInSubscribing(jqXHR, textStatus, errorThrown) {
alert(textStatus);
}

If I am entering values just like normal text the action is being invoked. But if I am trying to enter values like ‘myname@test.co.uk’ I am getting ‘404 not found’ error.

  • 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-14T05:54:13+00:00Added an answer on June 14, 2026 at 5:54 am

    how about sending it like this :

     $.ajax({
                    type: 'POST',
                    url: '/Info/SubscribeToNewsLetter',
                    data: {"email" : Id },
                    contentType: "application/json; charset=utf-8",
                    traditional: true,
                    success: subscribed,
                    error: errorInSubscribing
                });
    

    EDIT :

    try surrounding it inside double quotation:

     $.ajax({
                    type: 'POST',
                    url: '/Info/SubscribeToNewsLetter',
                     data: '{"email" : "' + Id + '"}',
                    contentType: "application/json; charset=utf-8",
                    traditional: true,
                    success: subscribed,
                    error: errorInSubscribing
                });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two MapRoute in global asax.` routes.MapRoute( AutoGeneratedURLHandler, // Route name {modulepath}/{controller}/{action}/{id}, //
I have this route declaration: routes.MapRoute( // Route name WhiteLabelPartners, // URL with parameters
How can I make an AJAX call to retrieve the URL of controller's action
Background info I have an app where users can make microsites ala http://myname.the_app.com .
In code igniter, you can connect database and make queries in controller like: $this->db->query(Your
I can make a variable's name from two variables' value: $a = 'tea'; $b
Can someone tell me how I can make the following output? I have a
I have an action-method in a controller that takes requests coming from a variety
I have a controller / action in an ASP.NET MVC3 app. It handles the
I have a Web API controller action which has a parameter of type CommandMessage.

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.