그렇게하는 도우미를 만들 수 있습니다. 의 URL 자체를 해결하기 위해 찾고 측면에서 예를 들어
...
public static string LinkedImage(this HtmlHelper html, string url)
{
Regex regex = new Regex("({(.*?)})");//This is off the top of my head regex which will get strings between the curly brackets/chicken lips/whatever! :).
var matches = regex.Matches(url);
foreach (var match in matches)
{
//Go get your value from the db or elsewhere
string newValueFromElsewhere = GetMyValue(match);
url = url.Replace(string.Format("{{0}}", match), newValueFromElsewhere);
}
return html.Image(url);
}
, 당신은 스티븐 발터의 블로그에 here을 볼 수도 있습니다.
이 요격을 어느 시점에서하고 싶습니까? 해당 애셋에 링크 된 페이지를 표시 할 때? 또는 요청이 웹 서버에 도착하면? –
페이지가 방문자에게 완전히 출력되기 전에 URL에있는 "{somefolder}"의 모든 인스턴스가 원하는 것으로 대체됩니다. 상대 URL이 절대 서버 측으로 해석 될 때 수행해야한다고 가정합니다. 그러나 확실하지 않습니다. – Omar