Reputation: 2392
I have a partial view that is been used in several places in the product. Within this view, I am doing a JSON call via Url.Action(“MyActionMethod ”,10)
that calls this method MyActionMethod from Home controller. My problem is when I use this partial view from a different place (let’s say MyView1 in context of AccountController ), its trying to search for Account/MyActionMethod whereas this method is available at Home/MyActionMethod . If I change code to Url.Action("/Home/MyActionMethod" ,10)
, it basically looks for Account/Home/MyActionMethod .
Any ideas?
Upvotes: 1
Views: 460
Reputation: 5480
You need to use the correct overload.
Url.Action("actioname","controllername",new {id:10})
Upvotes: 0
Reputation: 1038720
Url.Action("MyActionMethod", "MyController")
or if you are using areas and you want to specify the root:
Url.Action("MyActionMethod", "MyController", new { area = "" })
Upvotes: 3