URL, , Web.config( - ), URL- URL-.
public static MvcHtmlString CDNImageLink(this UrlHelper url, string imageName)
{
string urlFormat;
if((bool)ConfigurationManager.AppSettings["Debug"])
urlFormat = "/Content/Img/{0}";
else
urlFormat = "http://cdn.com/Img/{0}";
return MvcHtmlString.Create(string.Format(urlFormat, imageName));
}
, URL- ( HTML):
public static MvcHtmlString ActionLinkWithImage(this HtmlHelper html, string imageName)
{
UrlHelper Url = new UrlHelper(html.ViewContext.RequestContext);
string imageUrl = Url.CDNImageLink(imageName);
}
, using , Url , HTML, .