Guest User

Untitled

a guest
Sep 13th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <rewrite>
  2. <rules>
  3. <rule name="GetEnvironmentInfo">
  4. <match url=".*" />
  5. <serverVariables>
  6. <set name="Environment" value="Dev" />
  7. </serverVariables>
  8. <action type="Rewrite" url="{R:0}" />
  9. </rule>
  10. </rules>
  11. </rewrite>
  12.  
  13. string output = string.Empty;
  14. if (Request.Properties.ContainsKey("MS_HttpContext"))
  15. {
  16. output = ((System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.ServerVariables["Environment"];
  17. }
  18. else if (Request.Properties.ContainsKey("MS_OwinContext"))
  19. {
  20. var httpContextWrapper = ((OwinContext)Request.Properties["MS_OwinContext"]).Environment["System.Web.HttpContextBase"] as HttpContextWrapper;
  21. output = httpContextWrapper.Request.ServerVariables["Environment"];
  22. }
Advertisement
Add Comment
Please, Sign In to add comment