Guest User

Untitled

a guest
Oct 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class StaticFilesHttpHandler : IHttpHandler
  2. {
  3. public void ProcessRequest(HttpContext context)
  4. {
  5. if (context.Request.IsAuthenticated)
  6. {
  7. // continue with the request
  8. }
  9. else
  10. {
  11. throw new HttpResponseException(HttpStatusCode.Unauthorized);
  12. }
  13. }
  14.  
  15. public bool IsReusable => false;
  16. }
  17.  
  18. routes.RouteExistingFiles = true;
  19. routes.Add("helpRoute", new Route("folder/*.htm", new StaticFilesRouteHandler ()));
  20.  
  21. public class StaticFilesRouteHandler : IRouteHandler
  22. {
  23. public IHttpHandler GetHttpHandler(RequestContext context)
  24. {
  25. return new StaticFilesHttpHandler ();
  26. }
  27. }
  28.  
  29. <handlers>
  30. <add name="StaticFileHandler" verb="GET" path="~/help/default.htm" type="StaticFilesHttpHandler "/>
  31. </handlers>
Add Comment
Please, Sign In to add comment