Click here to Skip to main content
15,903,523 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am following the tutorial by [^].

For some reason , I just can't figure out what goes in Mime.Dat , VDirs.Dat and Default.Dat.

For ex. for Default.Dat just create a dat file with the line default.html default.htm Index.html Index.htm; ? Is that how it supposed to work ?

What I have tried:

Create your own Web Server using C#[^]
Posted
Updated 26-Nov-16 17:25pm
Comments
Peter Leow 26-Nov-16 23:26pm    
Post your question to the author of that article in the Comments and Discussion section of that article page https://www.codeproject.com/articles/1505/create-your-own-web-server-using-c#_comments

1 solution

The article description tells what to put in each file.
Mime.dat contains
".html; text/html .htm; text/html .gif; image/gif .bmp; image/bmp"
Vdirs.dat contains
"/; C:\myWebServerRoot/ /test/; C:\myWebServerRoot\Imtiaz\"
Default.dat contains
"default.html default.htm Index.html Index.htm;"

This assumes that you created your directory a "C:\myWebServerRoot" with a subdirectory of "C:\myWebServerRoot\Data"
The 3 files go into the data directory.
The program will read these files for the configuration on what to do with your webserver.
 
Share this answer
 
Comments
forte74 27-Nov-16 22:53pm    
just wondering, what kind of directory is that
C:\myWebServerRoot/ /test/; C:\myWebServerRoot\Imtiaz\"

C:\myWebServerRoot/ /test/... notice the spacing before test
forte74 28-Nov-16 0:20am    
everytime I try it, the program will look for a test.html file under C:\myWebServerRoot/ and for the line

sr = new StreamReader("data\\Mime.Dat");

it will return an empty string ??
forte74 28-Nov-16 0:24am    
mySocket.Send(bSendData, bSendData.Length, 0)
114
e
{"Could not find a part of the path 'C:\\Users\\ACER\\Documents\\Visual Studio 2013\\Projects\\webserver1\\webserver1\\bin\\Debug\\data\\Mime.Dat'."}
[System.IO.DirectoryNotFoundException]: {"Could not find a part of the path 'C:\\Users\\ACER\\Documents\\Visual Studio 2013\\Projects\\webserver1\\webserver1\\bin\\Debug\\data\\Mime.Dat'."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
HResult: -2147024893
InnerException: null
Message: "Could not find a part of the path 'C:\\Users\\ACER\\Documents\\Visual Studio 2013\\Projects\\webserver1\\webserver1\\bin\\Debug\\data\\Mime.Dat'."
Source: "mscorlib"
StackTrace: " at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)\r\n at System.IO.StreamReader..ctor(String path)\r\n at Imtiaz.MyWebServer.GetMimeType(String sRequestedFile) in c:\\Users\\ACER\\Documents\\Visual Studio 2013\\Projects\\webserver1\\webserver1\\Program.cs:line 101"
TargetSite: {Void WinIOError(Int32, System.String)}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900