SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Revisiting an old post

    I wrote a post about using Variables in CSS a while back (here).

    Someone asked a question about something similar so I thought I'd rewrite it for MVC3. It seems that adding the [OutputCache] to the method changes the ContentType from "text/css" to "text/html" causing the CSS to not be applied.
    Code Csharp:
    [OutputCache(VaryByParam = "none", Duration = 3600)]
     
    public ActionResult Index()
    {
     
    	var cssDefs = new Css();
     
    	cssDefs.Background = "808";
    	cssDefs.Width = "500px";
    	cssDefs.WrapperMargin = "0 auto";
    	cssDefs.Foreground = "ff0";
     
    	Response.Filter = new CSSCompressor(Response.Filter);
     
    	Response.ContentType = "text/css";
     
    	return View(cssDefs);
    }
    How would I go about keeping the ContentType and Caching the output?

  2. #2
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I moved the ContentType to the View.

    Code Csharp:
    @model CSSControl3.Models.Css 
    @{Layout = null;
      Response.ContentType = "text/css";}


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •