1

i am using output cache attribute to cache my page ,

[OutputCache(Duration = 50000)]
    public ActionResult GetRidOfZombies()
    {
       // Code 
    }

now the problem is that i have two domain running the same application abc.com and xyz.com i want to do that when any user see my site in xyz.com then this cache attribute trim down to [OutputCache(Duration = 50)] .... How should i do that . I searched it alot on google but didn't find any solution . Thanks in advance !

1 Answer 1

1

You could write a custom attribute:

public class MyDomainAwareOutputCacheAttribute : OutputCacheAttribute
{
    public override void OnResultExecuting(ResultExecutingContext filterContext)
    {
        // TODO: extract the domain from filterContext.HttpContext.Request.Url
        // and set the duration accordingly

        Duration = 50000;

        base.OnResultExecuting(filterContext);
    }
}

and then:

[MyDomainAwareOutputCache]
public ActionResult GetRidOfZombies()
{
    // Code 
}
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.