logo
down
shadow

"The parameters dictionary contains a null entry for parameter" - How to fix?


"The parameters dictionary contains a null entry for parameter" - How to fix?

By : user3857956
Date : January 02 2021, 06:48 AM
help you fix your problem That empty string for productId (in your default route) will get parsed to a null entry by the Framework, and since int does not allow null...you're getting the error.
Change:
code :


Share : facebook icon twitter icon
WebApi Put "The parameters dictionary contains a null entry for parameter..."

WebApi Put "The parameters dictionary contains a null entry for parameter..."


By : Fanare
Date : March 29 2020, 07:55 AM
I wish this help you , I am unable to reproduce the issue you are describing.
Model:
code :
public class Contact
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Phone { get; set; }
    public string Email { get; set; }
    public DateTime LastModified { get; set; }
}
public class ContactsController : ApiController
{
    public Contact Put(int id, Contact contact)
    {
        return contact;
    }
}
class Program
{
    static void Main()
    {
        using (var client = new WebClient())
        {
            client.Headers[HttpRequestHeader.ContentType] = "application/json";
            var data = Encoding.UTF8.GetBytes(@"{""Id"":3,""Name"":""mmm"",""Phone"":""000 000 0000"",""Email"":""mmm@gmail.com"",""LastModified"":""2012-03-08T23:42:13.8681395+08:00""}");
            var result = client.UploadData("http://localhost:1405/api/contacts/4", "PUT", data);
            Console.WriteLine(Encoding.UTF8.GetString(result));
        }
    }
}
PUT /api/contacts/4 HTTP/1.1
Content-Type: application/json
Host: localhost:1405
Content-Length: 119
Expect: 100-continue
Connection: Keep-Alive

{"Id":3,"Name":"mmm","Phone":"000 000 0000","Email":"mmm@gmail.com","LastModified":"2012-03-08T23:42:13.8681395+08:00"}
MVC3 and Ajax error "The parameters dictionary contains a null entry for parameter ..."

MVC3 and Ajax error "The parameters dictionary contains a null entry for parameter ..."


By : Umair Kardar
Date : March 29 2020, 07:55 AM
This might help you This is driving me nuts! , Your route
code :
routes.MapRoute(
        "EditProperty",
        "{controller}/{action}/{propertyID}",
        new {controller = "Property", action = "Edit"}
        );
routes.MapRoute(
        "EditProperty",
        "{controller}/{action}/{propertyID}",
        new {controller = "Property", action = "Edit"},
        new {controller = "Property", action="Edit"} // constraint
        );
How to globally handle "The parameters dictionary contains a null entry for parameter x"

How to globally handle "The parameters dictionary contains a null entry for parameter x"


By : Pascal
Date : March 29 2020, 07:55 AM
wish help you to fix your issue It's not exactly a global approach, but if your actions' parameters have sensible defaults, why not try just making them optional parameters? For example :
code :
public ActionResult Index(int id = 0, string name = "user") { ... }
ASP.net web api 2 error "The parameters dictionary contains a null entry for parameter"

ASP.net web api 2 error "The parameters dictionary contains a null entry for parameter"


By : Caroline Bindá
Date : March 29 2020, 07:55 AM
may help you . I have routes configured like this: , I believe this was problem in WebApiConfig I have these lines:
code :
config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new {id = RouteParameter.Optional}
            );

        config.Routes.MapHttpRoute("CustomApi", "{controller}/{action}/{id}", new {id = RouteParameter.Optional}
            );
 routes.MapHttpRoute("DefaultApi2", "api/{controller}/{action}/{id}", new {id = RouteParameter.Optional}
 config.Routes.MapHttpRoute("CustomApi", "api/{controller}/{action}/{id}", new { id = RouteParameter.Optional }
         );
        config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new {id = RouteParameter.Optional}
            );
  routes.MapRoute(
             name: "Default",
             url: "{controller}/{action}/{id}",
             defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
         );
Why do I get "The parameters dictionary contains a null entry for parameter" exception?

Why do I get "The parameters dictionary contains a null entry for parameter" exception?


By : Rohit Nigam
Date : March 29 2020, 07:55 AM
I wish this helpful for you Your form does not include a value for an id property so nothing for it is posted to the controller. You could include an input for it, but by default, the parameters in your GET method will be added to the forms action attribute when you use the BeginForm method. Delete your manual
element and replace it with
code :
@using (Html.BeginForm())
{
    ....
}
@Html.LabelFor(m => m.username)
// or @Html.LabelFor(m => m.username, "user name :") if you have not applied a [Display] attribute
@Html.TextBoxFor(m => m.username, new { @class="form-control" })
@Html.ValidationMessageFor(username)
@model RoleCheckbox
@Html.HiddenFor(m => m.id)
@Html.HiddenFor(m => m.name)
@Html.LabelFor(m => m.ischecked, Model.name)
@Html.CheckBoxFor(m => m.ischecked)
@Html.ValidationMessageFor(m => m.ischecked)
@Html.EditorFor(m => m.Roles)
Related Posts Related Posts :
  • Looking for a .Net ORM
  • Cost of SortedDictionary.Count
  • All possible combinations of n items selected randomly from a set of x items (algorithm)
  • Displaying process percentage on DOS screen
  • C# Importing Large Volume of Data from CSV to Database
  • c# control location precision
  • Printing to Zebra printer gives faint and blurry images
  • How to avoid stepping into dll code file?
  • Programmaticaly prevent Vista desktop search (WDS) from indexing pst files placed on mapped network drives
  • Is there anyway to reduce IsolatedStorage capacity in Silverlight?
  • C#: How to print a unicode string to console?
  • Frequency Table with Random Values
  • My Visual Studio 2008 web application keeps throwing a .Net error when I first run it, but refreshing fixes it
  • TCP Connection Creation and Closing Event Hooking
  • Find changed properties of a class
  • C#: Object with custom marshaller not containing data after PInvoke call
  • Version Control System with API. Need to get metrics
  • Performance comparison of Dictionaries
  • How to get process name and title of the top window on Windows / C#
  • How to save the ListView contents to a text file?
  • Why not .NET-style delegates rather than closures in Java?
  • Get CLSID by PIA interface Type
  • Visual Studio 2008 C# - Recover solution from application manifest possible?
  • Is a good practice to initialize private data members from within ctor by calling the associated properties instead of t
  • Inserting into a bitstream
  • How do you write byte[] array using log4.net
  • Clickonce + .NET client profile 4 framework + offline
  • Show form that showDialog from mainForm won't block it, but closing mainForm will close it
  • Developing a GPS car tracking system
  • dynamic log4net appender name?
  • Visual studio formatting issue
  • IndexOutOfRangeException when a stream is a multiple of the buffer size
  • How to deal with calculated values with Dependency Properties on a custom WPF control
  • counting from textbox,asp.net
  • Threading best practice when using SFTP in C#
  • how to load PDF file in website page using C#
  • Parent child class relationship design pattern
  • MessageQueue.BeginReceive() null ref error - c#
  • A C# collection, which behaves like C++ set or priority_queue?
  • Animating WPF buttons from inside a style
  • WPF Grid : GridSplitter event
  • Server 2008 Task Scheduler Mapped Drive Access C#
  • Cast problem with LINQ
  • Combo box Item source = ObservableCollection & I need a '-None-' dummy entry at the top
  • Which GUI control is suitable for this purpose?
  • Trying to access App.config file for mail settings but fails to work
  • Invoke PowerShell script from c# in runspace and get line number where error occured
  • How to show html contents with a RichTextBox?
  • FTP monitoring and downloading of new files
  • MEF + Plug-In not updating
  • Efficient handling of super wide, but not so tall, bitmap?
  • .NET 3.0 Unit Testing getting System.MethodAccessException calling .NET 2.0
  • Web Services vs Persistent Sockets
  • How do I dynamically reference incremented properties in C#?
  • Windows Installer (C#) error code 2869
  • Exception "The operation is not valid for the state of the transaction" using TransactionScope
  • Tools for listing database accesses from .NET code
  • Excel VSTO set selection
  • Creating a subscription based website in ASP.NET
  • Merging Resources Dictionaries
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk