Last post Dec 17, 2010 04:08 AM by santa_1975
Dec 17, 2010 03:52 AM|mm8|LINK
I am creating an ASP.NET MVC application and want to display an icon in the view based on a value of a property in the model. I guess I want to have the logic deciding which image to show in the business layer (which is in a separate class library project) but
the actual images files in the web application's "Content" folder. Should I set the url of the image in the business layer? I don't want the business layer to know that is serves a web application, it can be a Windows Form or WPF application as well. If I
set the url with System.Web.HttpContext.Current.Server.MapPath it feels like I am getting an unwanted dependency on System.Web, right? What are the options here?
Dec 17, 2010 04:08 AM|santa_1975|LINK
You can identify and assign a property to hold the name of the image in the business layer based on your logic.
Read this property and concatenate it with the path of the image source (may be from the web.config file) in the UI layer to assign it to the "img" tag.
Hope this helps.