This is a migrated thread and some comments may be shown as answers.

[Solved] WebAssetGroup.ContentType is null

3 Answers 123 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mario
Top achievements
Rank 2
Mario asked on 16 Nov 2010, 09:46 AM
Hi,

With the latest version of the Telerik MVC (2010.3.1110), when using shared web assets with .Combined(true), the WebAssetGroup.ContentType is null when running in the WebAssetHttpHandler.ProcessRequest(HttpContextBase context).

public override void ProcessRequest(HttpContextBase context)
{
    string id = context.Request.QueryString[IdParameterName];
 
    if (!string.IsNullOrEmpty(id))
    {
        WebAssetGroup group = SharedWebAssets.FindScriptGroup(id)
            ?? SharedWebAssets.FindStyleSheetGroup(id) ?? new WebAssetGroupSerializer().Deserialize(id);
         
        if (group != null)
        {
            HttpResponseBase response = context.Response;
 
            // Set the content type
            response.ContentType = group.ContentType;// This is null.
 
            string content = reader.Read(group);
 
            if (!string.IsNullOrEmpty(content))
            {
                // Compress
                if (group.Compress && !context.IsMono())
                {
                    httpResponseCompressor.Compress(context);
                }
 
                // Write
                using (StreamWriter sw = new StreamWriter((response.OutputStream)))
                {
                    sw.Write(content);
                }
 
                // Cache
                if (!context.IsDebuggingEnabled)
                {
                    httpResponseCacher.Cache(context, TimeSpan.FromDays(group.CacheDurationInDays));
                }
            }
        }
    }
}

This results in RebaseImagePathContentFilter.AppliesTo(string contentType) returning false in the WebAssetGroupReader.Read(WebAssetGroup group) method, thus not applying the filter for images in css-files.

public string Read(WebAssetGroup group)
{
    var appliesTo = filter.AppliesTo(group.ContentType);// This returns false (ContentType is null)
 
    var result = new StringBuilder();
 
    foreach (var asset in group.Items)
    {
        var path = locator.Locate(asset.Source, group.Version);
 
        var text = provider.ReadAllText(path);
 
        if (appliesTo)// Does not apply if ContentType is null. No images work for css.
        {
            var basePath = provider.GetDirectory(path);
 
            text = filter.Filter(basePath, text);
        }
 
        result.Append(text);
    }
 
    return result.ToString();
}

Is there a quick fix, maybe? I hope you can reproduce the bug.

Regards,
Mario I.

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 16 Nov 2010, 02:04 PM
Hi Mario,

 I was able to reproduce this bug. Fortunately it was an easy fix. Find attached the hotfix build.

I have updated your Telerik Points.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mario
Top achievements
Rank 2
answered on 16 Nov 2010, 03:14 PM
Yepp, that solved it.

Thanks Atanas!

Regards,
Mario
0
Greg Roberts
Top achievements
Rank 1
answered on 18 Nov 2010, 02:39 AM
Can you elaborate on this fix, I want to bring it into my custom version if possible. Your download only has binaries. Thanks!
Tags
General Discussions
Asked by
Mario
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Mario
Top achievements
Rank 2
Greg Roberts
Top achievements
Rank 1
Share this question
or