Sean Anderson
Sean Anderson

Reputation: 29331

Adding some automatic versioning to CSS files. How come I'm not able to pull assembly info?

<link rel="stylesheet" type="text/css" href="../Content/Dashboard/CustomTooltip.css?v=<%= System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion %>" />

Couple of questions:

Thanks

Edit: It seems like its something to do with the reflection that's going on. If I say:

System.Reflection.Assembly.GetExecutingAssembly().GetName().Name

I see the proper name in the watch window, but when evaluated on the .aspx page it is App_Web_35 (not correct). Any idea how to fix this?

Edit2: I ended up going with a solution I'm not quite happy with, but would love to hear other inputs. I just put:

protected string GetApplicationVersion()
{
    return System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
}

on my related CS page -- and then in the code behing I called <% GetApplicationVersion() %> and now it happily returns the proper information. I wish it could be inlined, though.

Upvotes: 1

Views: 1359

Answers (1)

dknaack
dknaack

Reputation: 60516

A css file is static, like html. Think about create different css files and call it like this

<link rel="stylesheet" type="text/css" href="../Content/Dashboard/CustomTooltip_<%= `System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAsse`m`bly().Location).FileVersion %>.css" />`

so you need a css file like this ../Content/Dashboard/CustomTooltip_1.0.css

Upvotes: 1

Related Questions