Reputation: 4662
I need to pass in the css file name to my razor page but I'm having difficulty getting the session to take.
Here is the line I have:
<link href="@Url.Content("~/Content/epp.css")" rel="stylesheet" type="text/css" />
I need to pass in 'epp' as a Session["Css"]
but I haven't figured out how to do this.
I have tried:
<link href="@Url.Content("~/Content/@HttpContext.Current.Session["Css"].ToString().css")" rel="stylesheet" type="text/css" />
but that wasn't working.
Any suggestions?
Upvotes: 2
Views: 207
Reputation: 27604
It seems that you want to do something like this:
<link href="@Url.Content("~/Content/" + HttpContext.Current.Session["Css"] + ".css")" rel="stylesheet" type="text/css" />
Upvotes: 1
Reputation: 139778
You need to build the url "by hand" (with string.Format
or with string concenation) for the Url.Content
argument
<link href="@Url.Content(string.Format("~/Content/{0}.css", HttpContext.Current.Session["Css"]))"
rel="stylesheet" type="text/css" />
Upvotes: 3