0

Possible Duplicate:
Can .NET intercept and change css files?

I have configured IIS6 to get .NET to handle css files.

I did the following steps

  • Launch IIS Manager
  • Right-click on Default Web Site
  • Click on the Home Directory tab
  • Under Application Settings click on Configuration...
  • Add a new association for .css and map it to .NET executable:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll

How can I check if this is working, i.e. I want to change the default style of a page depending on the url, i.e. if the referer url is http://intranet, it should continue to use the old existing style style1.css, if the referer url is http://intranetv2, it should use the new style style2.css.

Community
  • 1
  • 1
oshirowanen
  • 15,297
  • 82
  • 198
  • 350

2 Answers2

1

I would suggest that rather than doing this, you create a HTTP handler to serve your CSS file - this means that if you do have any static CSS files, they can continue to be dispatched quickly.

Example here:

http://aspnetresources.com/articles/variables_in_css


Final note from the comments below. In this case, what you could do is create you handler to serve your css file depending on the URL. In your project, do a 'replace in all files' of "mystylesheet.css" with "mystylesheethandler.ashx" and away you go.

Paddy
  • 33,309
  • 15
  • 79
  • 114
  • Yes, that is what I am trying to do. I just just setup the IIS6 server, now I want to test if it's working. – oshirowanen Jul 25 '11 at 10:05
  • The link you posted shows, how to make css files variable aware, I am trying to dynamically change the whole style sheet based on the referal url. – oshirowanen Jul 25 '11 at 10:09
  • I've just remembered I have another question just like this which I forgot about... Can't delete this question now to continue with that question... – oshirowanen Jul 25 '11 at 10:35
  • Your question isn't very clear, in this case. Surely this is then just a matter of adding a stylesheet in the master page, depending on the URL? What do you need to configure in IIS to do this? Would note that you could also do this in a handler. – Paddy Jul 25 '11 at 10:45
  • I can't use master pages because there were no master pages when I made those old pages with .net 1.0. It's all explained in my old question, so ideally, I need to close this question and continue with my old question for which I have added a bounty. – oshirowanen Jul 25 '11 at 11:16
0

You'd need to make changes to your web application itself, not IIS or .NET - they are the runtimes. They run your website, they don't modify it in any way. Those stylesheet changes are a core part of your application, you will need to program it yourself, detecting the URL (or having a separate application altogether) and use the appropriate stylesheet.

Furthermore, I'd like to add that .NET does not "handle" a CSS, or any other file other than PEs and DLLs (from which compiled code is executed). CSS is not compiled code - it does not execute any statements on a machine's processor.

foxy
  • 7,599
  • 2
  • 30
  • 34