Created
March 27, 2019 13:47
-
-
Save MichaelaIvanova/dfc1a372820ec3b3028bc4dcea80719f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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