5

Im developing an asp.net mvc 3 site that serves multiple domains. So based on the domains I show different content.

For example if its www.domain1.com, in homepage I show 3 images and some text. If its www.domain2.com in homepage I show only text.

I implemented a custom output cache provider called FileOutputCache, which saves the cached pages into files, and I would like to us it in this project. But I have a BIG problem, I dont have access to the request, nor to the host...

This is one of the operations: public override object Add(string key, object entry, DateTime utcExpiry);

You can see that I have no access to the host, and the key doesnt depend on it... So if I deploy the site and the first user enters to www.domain1.com, it will render and cache the page with 3 images and text.... and if another user enters to www.domain2.com, it will show the 3 images and text :(

Does anyone know how can I differentiate the request's host in my custom output cache provider?

Thanks in advance! Juan

1 Answer 1

6

I solved this by using VaryByHeader = Host

As the domain is in the host, which is a header, you can just use that built-in asp.net mvc functionality and it works fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.