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

  • Home
  • SEARCH
  • 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 3342396
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:50:01+00:00 2026-05-18T00:50:01+00:00

I am working on a runtime composite resource library for ASP.NET WebForms/MVC. I support

  • 0

I am working on a runtime composite resource library for ASP.NET WebForms/MVC. I support both standard ASP.NET WebForms via WebControls and have also recently added support for ASP MVC Html Helpers. One feature that I currently support with the WebForms WebControls is the concept of “Partial” resource definitions where a resource can be combined over the Master/View pages etc.

When implementing the MVC equivalent, I am not sure what the best practise is? I am currently leaning towards a design something like:

Master Page

<% using (Html.CreateCompositeResourcePartContext())
   {
     Html.CompositeCssResourcePart(
       "ResourceName", 
       new[] { "/Styles/SharedStyle1.css", "/Styles/SharedStyle2.css" }
     );
     %>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
<% } %>

Which will create a “context” wrapper around the head ContentPlaceholder.

View Page

<asp:Content ID="HeadContentPlaceholder" ContentPlaceHolderID="head" runat="server">
  <% Html.CompositeCssResourcePart(
     "ResourceName", 
     new[] 
     {
       "/Styles/PageStyle5.css",
       "/Styles/PageStyle6.css",
       "/Styles/PageStyle7.css"
     }) %>
</asp:Content>

So any view pages can extend the partial resource definition as seen above.

The questions I have:

1) Unlike all my other HtmlHelpers, these extensions do not immediately write out the HTML fragment but rather wait until the context is disposed. Should these extensions be off the ViewContext instead (or some other object)?

2) I personally think the concept of a “using” makes sense to wrap a block of code rather than separate BeginCompositeResourcePartContext/EndCompositeResourcePartContext calls, would you agree? If no, what is better about separate method calls?

Any feedback on the above would be greatly appreciated. If more detail is required, please let me know.

Edit

To clarify… the block inside the head of the Master page and the subsequent reference in side a view page will be combined together in to a single resource. So when the context of CompositeResourcePartContext is disposed, all SIX files are combined in to only ONE css file and written out as a single link TAG (or script, css sprite etc)

<link rel="stylesheet" type="text/css" href="/MyMergedStyleSheet.css" />
  • 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-18T00:50:01+00:00Added an answer on May 18, 2026 at 12:50 am

    After giving it some more thought (and consulting a colleague) I feel that the best option is to stick with my original plan of not polluting my ASP.NET MVC API with the concept of “partial” resource definitions (works for WebControls, but not as nice with MVC in my opinion). Prior to considering an explicit HtmlHelper extension for this case in my library, I suggested that the issue can be handled by defining a custom extension method as follows:

    public static class CustomXpediteExtensions
    {
        private static readonly IEnumerable<String> SharedCss = new[]
        {
            "/Styles/SharedStyle1.css",
            "/Styles/SharedStyle2.css",
            "/Styles/SharedStyle3.css"
        };
    
        public static MvcHtmlString CustomCompositeCssResource(this HtmlHelper htmlHelper, params String[] resources)
        {
            return htmlHelper.CompositeCssResource(SharedCss.Concat(resources));
        }
    }
    

    And then simply referencing that custom extension (or constant, etc.) in the view page.

    <asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
      <%= Html.CustomCompositeCssResource(
            "/Styles/PageStyle5.css",
            "/Styles/PageStyle6.css",
            "/Styles/PageStyle7.css"
          ) %>
    </asp:Content>
    

    This will allow you to not repeat yourself when combining shared resources (i.e., ensuring consistency) and ultimately handle the case.

    I will leave this open for a while to see if there is any feedback on this; but unless a good case is made for why this is not acceptable, I think it is the answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
Working on a project at the moment and we have to implement soft deletion
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a somewhat complex page for configuring customers at work. The setup is
Working on a project that parses a log of events, and then updates a
Working with python interactively, it's sometimes necessary to display a result which is some
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
Working with TCL and I'd like to implement something like the Strategy Pattern .
Working on a project where a sequential set of methods must be run every

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.