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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:01:32+00:00 2026-06-06T06:01:32+00:00

I have this controller: public class StandingsController : Controller { public ViewResult Index(int id)

  • 0

I have this controller:

public class StandingsController : Controller
{
    public ViewResult Index(int id)
    {

    }

    [HttpPost]
    public JsonResult GetStage(int stage, int leagueid)
    {

    }
}

Ajax call:

 $.ajax({
            url: '@Url.Action("GetStage", "Standings")',
            type: 'POST',
            data: { stage: currentStage, leagueid:leagueid },
            success: function (data) {
                    .............

I make an ajax request after page loads.
All i want is to change the url from http://localhost/MyApp/Standings/Index/3 to http://localhost/MyApp/Standings/3.
I added a custom route as follows:

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
 routes.RouteExistingFiles = false;
            routes.MapRoute(null, "Standings/{id}", new { controller = "Standings", action = "Index" });
 routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

but now i get an exception when making ajax call:

   The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ViewResult Index(Int32)' in 'MyApp.Controllers.StandingsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.

I don’t understand what has ajax call to do with that id parameter from the ViewResult.
I really need some help with this. Thanks.

  • 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-06T06:01:33+00:00Added an answer on June 6, 2026 at 6:01 am

    It is expecting an id. Try either this:

    url: '@Url.Action("GetStage", "Standings", new { id = 1 })',
    

    …or this:

    routes.MapRoute(null, "Standings/{id}", 
        new { controller = "Standings", action = "Index" }
        new { id = UrlParameter.Optional, });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this timer in c#: public class HomeController : Controller { public int
I have this code for my Spring-based web project: Controller: @Controller @RequestMapping(mycontroller) public class
I have this controller: [HttpPost] public ActionResult Create(Company company) { // try to save
I have this controller: public JsonResult Register(string step , GlobalOnBoardingDataModel data){} the MVC wont
I have this Controller : @Controller @RequestMapping(/path/*) public class MyController { @RequestMapping(value = /,
I have a very simple MVC app at this point: Controller: public class HomeController
I have the following scenario: public class Controller { private ModelRepository repository; public int
New to mvc, I have a controller like this public ActionResult Index(DateTime Date, DateTime
I have this code that works. public class HelloWorldController : Controller { UAStagingEntities db
I have got this controller: public class NewPostController : Controller { List<SelectListItem> languages= new

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.