Pass allowed extensions requests
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using VAR.Focus.Web.Code;
|
||||
|
||||
@@ -93,6 +94,10 @@ namespace VAR.Focus.Web
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(ex is ThreadAbortException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GlobalErrorHandler.HandleError(context, ex);
|
||||
}
|
||||
}
|
||||
@@ -108,6 +113,23 @@ namespace VAR.Focus.Web
|
||||
{
|
||||
file = Globals.DefaultHandler;
|
||||
}
|
||||
|
||||
// Pass allowed extensions requests
|
||||
string extension = Path.GetExtension(context.Request.FilePath).ToLower();
|
||||
if(Globals.AllowedExtensions.Contains(extension))
|
||||
{
|
||||
string filePath = context.Server.MapPath(string.Format("~/{0}", context.Request.FilePath));
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
context.Response.Buffer = true;
|
||||
context.Response.WriteFile(filePath);
|
||||
context.Response.Flush();
|
||||
context.Response.Close();
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IHttpHandler handler = GetHandler(file);
|
||||
if (handler == null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VAR.Focus.Web
|
||||
{
|
||||
public static class Globals
|
||||
@@ -8,5 +10,6 @@ namespace VAR.Focus.Web
|
||||
public const string Author = "Valeriano Alfonso Rodriguez";
|
||||
public const string Copyright = "Copyright (c) 2015 by Valeriano Alfonso, All Right Reserved";
|
||||
public const string DefaultHandler = "FrmBoard";
|
||||
public static List<string> AllowedExtensions = new List<string>{ ".png", ".jpg", ".jpeg", ".gif", ".ico", ".wav", ".mp3", ".ogg", ".mp4", ".webm", ".webp" };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user