coding/asp.net

@Url.Content("~/Home/Index"), @Url.Action("Index", "News")

사과키라임파이 2022. 4. 22. 15:38

@Url.Content("~/Home/Index")

@Url.Action("Index", "News")

 

 

Url.Content vs Url.Action


Url.Content
   - 사이트의 파일이나 리소스에 대한 URL을 확인하고 상대 경로를 전달(이미지 등)






Url.Action
   - 컨트롤러에서 작업을 해결하는 데 사용(페이지 이동 및 데이터 전달)

https://riucc.tistory.com/705

 

[ASP.NET MVC] - Url.Content vs Url.Action

○ Url.Content vs Url.Action Url.Content  - 사이트의 파일이나 리소스에 대한 URL을 확인하고 상대 경로를 전달(이미지 등) @Url.Content("~/path/file.htm") @Html.Raw(Resources.LangRes.lblTitle)    U..

riucc.tistory.com

 

 

Url.Content사이트의 파일이나 리소스에 대한 URL을 확인하고 상대 경로를 전달할 때 사용됩니다.

@Url.Content("~/path/file.htm")

Url.Action다음과 같은 컨트롤러의 작업을 해결하는 데 사용됩니다.

@Url.Action("ActionName", "ControllerName", new { variable = value })

자세한 내용은 여기를 참조하세요.

 

 

 액션 이동 : @Html.ActionLink() 


- 액션 이동 : @Html.ActionLink()
     액션 이동을 할 수 있는 링크에 값을 넣어 보낼 수도 있고,
     클래스와 스타일 등 다양한 기능도 줄 수 있다


@Html.ActionLink("상세보기", "Details", null, new { id = item.boardNo }, new { @class = "btn btn-info", @style = "margin-right:10px;" })


// ActionLink("보여질 문자열", "액션명", "컨트롤러명", 넣어줄 값, html속성)
public static string ActionLink(string linkText, string actionName, string controllerName, object values, object htmlAttributes)

https://riucc.tistory.com/620?category=784430