Option 1
Rather than change your CSS file apply different classes based on the session.
.main
{
padding: 0px 12px;
margin: 0px 0px 0px 0px;
min-height: 630px;
width:auto;
}
.agency1 { background-image: url('agency1.png'); }
.agency2 { background-image: url('agency2.png'); }
.agency3 { background-image: url('agency3.png'); }
Then add two classes to your div
<div class="main <%=Session["agency"]%>"></div>
Option 2
Create a Generic Handler that renders the specific CSS and add that to your page
<link href="GenerateCss.ashx" rel="stylesheet" />
In your GenerateCss.ashx.cs file you would have something like this
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string image = "main";
if (context.Session != null && context.Session["agency"] != null)
{
image = context.Session["agency"].ToString();
}
string result = ".main{padding: 0px 12px; margin: 0px 0px 0px 0px; min-height: 630px; width:auto; background-image:url('" + image + ".png');}";
context.Response.Write(result);
}
Be extremely careful as this could set you up for an XSS attack if used improperly You'll need to make sure that session["agency"] is not user controllable. By that I mean that the user cannot supply that value as this would allow them to inject anything they want in there.
I don't recommend the second option though because you're going to be calling this for every request and not a good idea to keep generating CSS when you can just make it static. If you can use option 1, I would say it would be better.