Menu call does not enter Action

Asked

Viewed 44 times

0

I have this menu in _Layout.cshtml

 @if (Response.Cookies["UserSession"]["UserRole"] == "Rh" || Response.Cookies["UserSession"]["UserRole"] == "Admin")
                        {
                            <li>
                                <a href="#"><i class="fa fa-bar-chart-o"></i> RH - Relatórios<span class="fa arrow"></span></a>
                                <ul class="nav nav-second-level">
                                    <li>
                                            @Html.ActionLink("Financiamento de veículos", "ExcelFinancing", "FinancingReport")
                                        </li>
                                </ul>
                            </li>
                        }

The problem is that when calling this menu item, it should stop at the break inside the Action in the controller. This is the Action in the controller

[HttpGet]
public ActionResult ExcelFinancing(DateTime dateFinancing)
{
     var t = 1 * 9;//Teste apenas, break aqui
     return null;
}

What happens is that when I click on this Menu item, it gives me the error of type 500, Internal server error (handled by .net). How do I sign in to the controller by calling Menu?

NOTE: I have another view called View.cshtml that inherits from _Layout.cshtml and in it I have other functions. Should I do something from it? Or the call only in _Layout.cshtml would be sufficient?

  • Dude, I tested it here and apparently you’re right, the only thing I figured out that could be wrong is your controller’s name not to fall in there, it’s named Financingreportcontroller?

  • 1

    Mounting a link is not passing the "dateFinancing parameter"

  • Take a test, try removing the "Datetime dateFinancing" parameter from your Action and see if it works.

  • @Brunosoares, removed the parameter and now paused in break. If reply, I mark.

1 answer

1


Your action has a dateFinancing Datetime parameter, but in your Actionlink you are not passing this parameter.

Either remove the action parameter, or try something like this on your link:

@Html.ActionLink("Financiamento de veículos", "ExcelFinancing", "FinancingReport", new { dateFinancing = null })

Since you must replace the parameter null by the date you want to pass as parameter.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.