Answer
Posting this here as 8 hours hasnt passed for me to answer my own question:
I figured this out. I removed Server.MapPath from the PreRender and it rendered it correct. Brain fart on my part. Thanks guys
in my code i have:
CssIncludes.Add("~/Sites/0/PageLayouts/Predefined/News/CSS/HeaderMenu.css");
Once rendered on page it comes out in the page source as:
<link href='C:\inetpub\wwwroot\mysite\Sites\0\PageLayouts\Predefined\News\CSS\HeaderMenu.css' type='text/css' rel='stylesheet' />
now if i manually copy that css url and paste it in my browser, it loads the css fine, yet it will not show up on my c:\localhost\mysite\ at all!
Any solutions?
CSS Includes list:
public List<string> CssIncludes
{
get
{
if (_cssincluded == null)
_cssincluded = new List<string>();
return _cssincluded;
}
}
void Page_PreRender(object sender, EventArgs e)
{
foreach (string css in CssIncludes)
{
Page.Header.Controls.Add(new LiteralControl(string.Format("<link href='{0}' type='text/css' rel='stylesheet' />", Server.MapPath(css))));
}
}
remove ~ sign and try again, i hope it will work
Add website path key in web.config in appSettings section
<add key="Websitepath" value="http://www.yoursite.com" />
and make url like
includeCss(ConfigurationManager.AppSettings["Websitepath"].ToString()+"Sites/0/PageLayouts/Predefined/News/CSS/HeaderMenu.css";