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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:21:46+00:00 2026-05-27T23:21:46+00:00

SOLUTION the route routes.MapRoute( Whatever, // Route name {controller}/{action}/{id}, //{ID} MUST BE USED IN

  • 0

SOLUTION

the route

 routes.MapRoute(
      "Whatever", // Route name
      "{controller}/{action}/{id}", //{ID} MUST BE USED IN YOUR CONTROLLER AS THE PARAMETER 
      new { controller = "MyController", action = "MyActionName", id = UrlParameter.Optional } // Parameter defaults
  );

And that’s it! I guess you must use the name of the id in the
public actionresult(int id //must be ID HERE like global.asax)

Steps to reproduce my problem: 
1. Create a new mvc3 application
2. Go to home controller and put Index(int? x){ return view()}
3. Run the application
4. Go to the url type in the url http://localthost:someport/Home/Index/1
5. Insert a break point in controller to see the value of x 
6. Notice that even if you put the url above x NOT equal to 1 as is suppose to!

I just dont understand why i am getting a null in the id….

 public ActionResult MyActionName(int? id)
    {
       //the id is null!!!!!!!!!!!! event thought i just entered the url below!
    }

I enter the following url in my browser
http://locahost/MyController/MyActionName/1

//I also put this in my global.asax but it doesnt really help.

   routes.MapRoute(
      "Whatever", // Route name
      "{controller}/{action}/{id}", // URL with parameters
      new { controller = "MyController", action = "MyActionName", id = UrlParameter.Optional } // Parameter defaults
  );

AND!
My error if I put

  public ActionResult MyActionName(int id)
        {
           //the id is null!!!!!!!!!!!! event thought i just entered the url below!
        }

Note that the above example was made for simplicity this error is for the actual application.

Server Error in ‘/’ Application.

The parameters dictionary contains a null entry for parameter ‘MvrId’ of non-nullable type ‘System.Int32’ for method ‘System.Web.Mvc.ActionResult Index(Int32)’ in ‘MedicalVariance.Controllers.MedicineManagementController’. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The parameters dictionary contains a null entry for parameter ‘MvrId’ of non-nullable type ‘System.Int32’ for method ‘System.Web.Mvc.ActionResult Index(Int32)’ in ‘MedicalVariance.Controllers.MedicineManagementController’. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters

  • 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-27T23:21:47+00:00Added an answer on May 27, 2026 at 11:21 pm

    Make sure your route is defined before the default route.

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

Sidebar

Related Questions

So I have this route mapped: routes.MapRoute( Solutions, {lang}/Solutions/{controller}/{action}, new { lang=en-US, controller =
route : routes.MapRoute(Default, {controller}/{action}/{id}/{args1}/{args2}/{args3}, // URL with parameters new { controller = Home, action
I have site culture in URLs like this: routes.MapRoute( Default, {language}/{controller}/{action}/{id}, languageDefaults, languageConstraints) And
I used Shay Jacoby's solution to route 404s and 500s and it works great
Solution is called Portal which holds Areas/CMS/Login folder inside it. Login controller in CMS/Controllers
redirect_to :controller=>'groups',:action=>'invite' but I got error because redirect_to send GET method I want to
I have created a route plus controller for doing dynamic css in ruby on
I have a route routes.MapPageRoute(clientOrder, Contract/{contractId}/Orders, ~/ContractOrders.aspx); The idea is to authorize user to
I've got a blogs_controller with a Blog resource, so I've got your typical routes
I am trying to create a route and a action that redirects the params.

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.