Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6663405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:29:43+00:00 2026-05-26T02:29:43+00:00

I am working on a plug-in architecture for widgets on a website. I would

  • 0

I am working on a plug-in architecture for “widgets” on a website. I would like each individual widget to store its Javascript and CSS as resources in the assembly. When the page is rendered, I inject script tags that reference a WCF service that can inspect the widget, extract the desired file, and send it back to the browser.

This is working fine for the Javascript files, but the browser can’t handle the CSS file coming through as an octet stream. Normally, you can just change the content type of the response in HttpContext, but that’s not available in a WCF service.

What I need is to have the browser retrieve these files through a url like so:

<link type="text/css" rel="stylesheet" href="/Controllers/WidgetFileService.svc/style/WidgetId">

I would prefer not to implement a custom IHttpHandler, because, in my experience, those can be difficult to deploy, debug, and get working on different machines. This is my first project at this company and I would rather not complicate deployment and testing.

Here is what I have for the interface:

[ServiceContract]    
public interface IWidgetFileService
{
    [OperationContract]
    [WebGet(UriTemplate = "style/{widgetID}", BodyStyle = WebMessageBodyStyle.Bare)]
    System.IO.Stream GetStyleFile(String widgetID);
}

And the implementation:

static private System.IO.Stream StreamBytes(byte[] data)
{
    System.IO.Stream s = new System.IO.MemoryStream(data);
    s.Position = 0;
    return s;
}

public System.IO.Stream GetStyleFile(String widgetID)
{
    IWidget w = GetWidget(widgetID);
    return StreamBytes(w.GetEditorStyleFile());            
}

If I browse to the URL, the data comes back as expected. It seems to be the way the browser is handling the request that is causing the issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:29:44+00:00Added an answer on May 26, 2026 at 2:29 am

    You can use the WebOperationContext to get access to the outgoing response in a WCF service. I’ve verified this sends it to the browser with the specified content type.

        public System.IO.Stream GetSytleFile(String widgetID)
        {            
            IWidget w = GetWidget(widgetID);
            WebOperationContext.Current.OutgoingResponse.ContentType = "text/css";
            return StreamBytes(w.GetEditorStyleFile());
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a browser plug-in for Firefox, and I would like to
I am working on a asp.net website. There are a lot of javascript plug-ins
I am working with an unnamed javascript plug-in. During a certain operation of said
I've been working on an Eclipse plug-in project for a while now, and I've
When I'm working at home I plug my MacBook in to my 20 monitor
I'm working on a web application and using the jQuery plug-in Colorbox to pop
I'm working on a project in C#, it's about E-learning.This project should use plug-ins
By ASP.NET MVC plugin architecture, Plug-in architecture for ASP.NET MVC I have separated DLL(plugin)
it's a very easy question maybe, but i can't find any working plug in
I'm currently working on a plug-in for Eclipse that translates some custom Java code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.