'MVC @Url.Content vs @Url.Action

I have looked online but was unable to find the difference between using @Url.Content vs @Url.Action.



Solution 1:[1]

@Url.Action is used to create a URL to an Action in a controller. For example, assuming you had a controller that looked like this:

public YourControllerController : Controller
{
    public ActionResult YourAction() { /* stuff */ }
}

You could create a URL that invokes the action with it like this:

Url.Action("YourAction", "YourController")

@Url.Content resolves a virtual path into an absolute path. Example:

Url.Content("~/images/image.jpg")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1