Skip to content

Instantly share code, notes, and snippets.

@MichaelaIvanova
Created March 27, 2019 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelaIvanova/dfc1a372820ec3b3028bc4dcea80719f to your computer and use it in GitHub Desktop.
Save MichaelaIvanova/dfc1a372820ec3b3028bc4dcea80719f to your computer and use it in GitHub Desktop.
public class NameFilterAttribute : ActionFilterAttribute
{
public override void OnResultExecuted(ResultExecutedContext resultExecutedContext)
{
string companyName = resultExecutedContext.Controller.TempData["SomeName"] as string;
string localPathUrl = resultExecutedContext.Controller.TempData["LocalPath"] as string;
Dictionary<string, string> stringReplacementDictionary = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(companyName))
{
stringReplacementDictionary.Add(ConfigHelper.GetValue("NameToReplace"), companyName);
}
if (!string.IsNullOrEmpty(localPathUrl))
{
stringReplacementDictionary.Add(ConfigHelper.GetValue("PathToReplace"), localPathUrl);
stringReplacementDictionary.Add(ConfigHelper.GetValue("NameToReplace"), localPathUrl);
}
resultExecutedContext.HttpContext.Response.Filter = new MemoryStreamHelper(resultExecutedContext.HttpContext.Response.Filter, stringReplacementDictionary);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment