Using Url.Action method in ASP.Net MVC

Last Reply 7 months ago By dharmendr

Posted 7 months ago

The resource cannot be found.

 i have controller viewmodel and view

from code in controller when i click the view name and go to view the cshtml file gets opened

but during run time hen i click a link to open the same view file i get the above error

this is the url

whts going wrong

<a href="@Url.Action("InfoAdd", "Info")"><strong>Add Information</strong></a>


Posted 7 months ago Modified on 7 months ago

Hi svibuk,

Check the actionName and the routeValues.

As per your code @Url.Action requires two parameter string and object Action(String, Object)

actionName - The name of the action method.

Type: System.String

routeValues - An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

Type: System.String

Ensure you are passing valid parameter.

I agree, here is the link: