locked
Server error in 'Directory; Application RRS feed

  • Question

  • User1697794668 posted

    I got an error: 
    The parameters dictionary contains a null entry for parameter 'k' of non-nullable type 'System.Int32'

    Can I confirm that the subdirectory can be access via directory/k/2 or directory?k=2

    Please advise thanks.

    Btw, can I check if 4.0.30319 and ASP.NET Version : 4.7.3650.0 is up to date?

    Tuesday, August 25, 2020 1:01 AM

All replies

  • User1535942433 posted

    Hi alvinoo,

    Is your application asp.net core?I guessing that you have used  the default route which is defined as this:

    endpoints.MapControllerRoute(
        name: "default",
        pattern: "{controller=Home}/{action=Index}/{id?}");

    The key part of that route is the {id} piece. If you look at your action method, your parameter is k instead of id. You need to change your action method to this so that it matches the route parameter:

    [Route("Home/About")]
    [Route("Home/About/{id?}")]
    public IActionResult About(int? id)
    { return ControllerContext.MyDisplayRouteInfo(id); }

    More details,you could refer to below article:

    https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-3.1

    Btw, can I check if 4.0.30319 and ASP.NET Version : 4.7.3650.0 is up to date?

    If you have error,you could accroding to your requirments to update.More details,you could refer to below article:

    https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed

    Best regards,

    Yijing Sun

    Tuesday, August 25, 2020 6:05 AM
  • User1697794668 posted

    Can I clarify if need to invoke the parameter it is like Home/About/1 Home/About/2 Home/About/3

    Tuesday, August 25, 2020 6:19 AM
  • User1535942433 posted

    Hi alvinoo,

    Accroding to your description,I don't understand your reuqirment clearly.

    The first path segment, {controller=Home}, maps to the controller name.The second segment, {action=Index}, maps to the action name.The third segment, {id?} is used for an optional id. The ? in {id?} makes it optional. id is used to map to a model entity.

    You could pass a parameter to link in page.If your project is asp.net core mvc ,you could refer to below this:

    <a asp-controller="Product" asp-action="GetProduct" asp-route-id="10"> ProductName</a>

    Best regards,

    Yijing Sun

    Tuesday, August 25, 2020 9:00 AM