controller issue

rashmitha r 21 Reputation points
2022-06-13T10:05:09.147+00:00

Hello, Iam passing project id using angular script "$scope.RenewalPDC.ProjectDetailId = $routeParams.Id;" but its passing 0 value in controller.. how to solve this?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,241 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 57,891 Reputation points
    2022-06-13T14:56:06.893+00:00

    debug why its zero. perhaps $routeParams.Id is zero.

    0 comments No comments

  2. Zhi Lv - MSFT 32,046 Reputation points Microsoft Vendor
    2022-06-14T02:18:02.15+00:00

    Hi @rashmitha r ,

    The default value of the Int type is 0. So, the issue might relate that the $routeParams.Id is 0 or the parameter name is not matched, so the int type will use the default value.

    You can refer the following steps to debug your code:

    First, as Bruce said, check the $routeParams.Id, whether it is zero or not?
    Second, use F12 developer tools to check transfer data in the http request, check the parameter name and value whether they are correct.
    Finally, in the Controller, check the parameter name, make sure it's using the same parameter name to receive the value.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    0 comments No comments

  3. rashmitha r 21 Reputation points
    2022-06-14T04:40:25.63+00:00

    thank you for your time, values are passing in but even though data is in scope ".success(function (data) {" it is going inside the function. 211098-data.png