diff --git a/WebServer.Sample/Program.cs b/WebServer.Sample/Program.cs
index bbe3b0d..fadbe0b 100644
--- a/WebServer.Sample/Program.cs
+++ b/WebServer.Sample/Program.cs
@@ -16,6 +16,7 @@
using System.Text;
using System.Net;
using System.Security.Cryptography.X509Certificates;
+using WebServer.Sample;
#if HAS_WIFI
using Windows.Devices.WiFi;
@@ -331,7 +332,10 @@ private static void ServerCommandReceived(object source, WebServerEventArgs e)
ApiDefault(e);
}
}
-
+ else if (url.ToLower().IndexOf("/favicon.ico") == 0)
+ {
+ WebServer.SendFileOverHTTP(e.Context.Response, "favicon.ico", Resources.GetBytes(Resources.BinaryResources.favicon));
+ }
#if HAS_STORAGE
else
{
diff --git a/WebServer.Sample/Resources.Designer.cs b/WebServer.Sample/Resources.Designer.cs
new file mode 100644
index 0000000..63a7fbd
--- /dev/null
+++ b/WebServer.Sample/Resources.Designer.cs
@@ -0,0 +1,38 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace WebServer.Sample
+{
+
+ internal partial class Resources
+ {
+ private static System.Resources.ResourceManager manager;
+ internal static System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((Resources.manager == null))
+ {
+ Resources.manager = new System.Resources.ResourceManager("WebServer.Sample.Resources", typeof(Resources).Assembly);
+ }
+ return Resources.manager;
+ }
+ }
+ internal static byte[] GetBytes(Resources.BinaryResources id)
+ {
+ return ((byte[])(nanoFramework.Runtime.Native.ResourceUtility.GetObject(ResourceManager, id)));
+ }
+ [System.SerializableAttribute()]
+ internal enum BinaryResources : short
+ {
+ favicon = -22914,
+ }
+ }
+}
diff --git a/WebServer.Sample/Resources.resx b/WebServer.Sample/Resources.resx
new file mode 100644
index 0000000..149ef4f
--- /dev/null
+++ b/WebServer.Sample/Resources.resx
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ Resources\favicon.ico;System.Byte[], mscorlib, Version=1.9.1.0, Culture=neutral, PublicKeyToken=c07d481e9758c731
+
+
\ No newline at end of file
diff --git a/WebServer.Sample/Resources/favicon.ico b/WebServer.Sample/Resources/favicon.ico
new file mode 100644
index 0000000..03a028f
Binary files /dev/null and b/WebServer.Sample/Resources/favicon.ico differ
diff --git a/WebServer.Sample/WebServer.Sample.nfproj b/WebServer.Sample/WebServer.Sample.nfproj
index 137101a..cb415b9 100644
--- a/WebServer.Sample/WebServer.Sample.nfproj
+++ b/WebServer.Sample/WebServer.Sample.nfproj
@@ -25,6 +25,11 @@
+
+ True
+ True
+ Resources.resx
+
@@ -38,6 +43,11 @@
True
True
+
+ ..\packages\nanoFramework.ResourceManager.1.1.2-preview.11\lib\nanoFramework.ResourceManager.dll
+ True
+ True
+
..\packages\nanoFramework.Runtime.Events.1.8.2-preview.10\lib\nanoFramework.Runtime.Events.dll
True
@@ -84,6 +94,15 @@
True
+
+
+ nFResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
+
diff --git a/WebServer.Sample/packages.config b/WebServer.Sample/packages.config
index 4af3204..05fc831 100644
--- a/WebServer.Sample/packages.config
+++ b/WebServer.Sample/packages.config
@@ -1,6 +1,7 @@
+
diff --git a/WebServer/WebServer.cs b/WebServer/WebServer.cs
index f323899..375e371 100644
--- a/WebServer/WebServer.cs
+++ b/WebServer/WebServer.cs
@@ -418,38 +418,8 @@ public static void OutputHttpCode(HttpListenerResponse response, HttpStatusCode
///
public static void SendFileOverHTTP(HttpListenerResponse response, StorageFile strFilePath)
{
- string ContentType = "text/html";
- //determine the type of file for the http header
- if (strFilePath.FileType.ToLower() == ".cs" ||
- strFilePath.FileType.ToLower() == ".txt" ||
- strFilePath.FileType.ToLower() == ".csproj"
- )
- {
- ContentType = "text/plain";
- }
- else if (strFilePath.FileType.ToLower() == ".jpg" ||
- strFilePath.FileType.ToLower() == ".bmp" ||
- strFilePath.FileType.ToLower() == ".jpeg" ||
- strFilePath.FileType.ToLower() == ".png"
- )
- {
- ContentType = "image";
- }
- else if (strFilePath.FileType.ToLower() == ".htm" ||
- strFilePath.FileType.ToLower() == ".html"
- )
- {
- ContentType = "text/html";
- }
- else if (strFilePath.FileType.ToLower() == ".mp3")
- {
- ContentType = "audio/mpeg";
- }
- else if (strFilePath.FileType.ToLower() == ".css")
- {
- ContentType = "text/css";
- }
-
+ string ContentType = GetContentTypeFromFileName(strFilePath.FileType);
+
try
{
IBuffer readBuffer = FileIO.ReadBuffer(strFilePath);
@@ -651,6 +621,7 @@ private void ListInterfaces()
}
}
+ /// Get the MIME-type for a file name.
///
/// Dispose of any resources.
///