Tengo esta etiqueta de imagen: <img src="url goes here" />
La acción de mi controlador se ve así:
public string GetProfilePhotoPath(){ var userId = User.Identity.GetUserId(); var userImage = db.Users.FirstOrDefault(u => u.Id == userId).ProfilePhotoPath; return userImage; } userImage contiene algo como esto: ~/Content/img/users/userABCD.png
Ahora mi pregunta es, ¿cómo llamo al controlador y obtengo la ruta para poder pasarla a src ?
tal vez algo como esto:
<img src="@Url.Content("~/Content/img/users/" + ControllerB().GetProfilePhotoPath()" alt="" />ejemplo llamando desde otro controlador, "ControllerB" será el nombre real de su controlador ControllerB (parte receptora):
var result = new ControllerB().GetProfilePhotoPath();o puede intentar usar un ViewBag ?
ViewBag.MyString = myString;Entonces lo usarías como
img src="@Url.Content("~/Content/img/users/" + @ViewBag.MyString" alt="" />