Please help know how to get file content type in C#.net.
For example, I create one asp.net project and hosted in server. So, now I can upload any time of file.
For example:- User uploaded demo.txt file. It done successfully!
Now user can view that file for example http://ip addres[255.255.255.255]/demowebsite/uploads/demo.txt
So, using that URL user can access that .txt file.
Now problem is, if user uploaded .aspx file or .ashx file or any other .net related file.
he can access that file using URL
For example user is uploaded a crack.aspx file with some virus program.
So, now he can execute his code by browsing http://ip addres[255.255.255.255]/demowebsite/uploads/crack.aspx .
I want to handle this error. if he uploaded any text content type file, I need to change those file extensions to crack.aspx.txt or crack.php.txt or crack.jsp.txt or demo.xml.txt. Because those are content type is Text.
For this we can use this code below code to find content type
private string MimeType (string Filename)
string mime = "application/octetst ream ";
string ext = System.IO.Path.GetExtension(Filename).ToLower();
Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.ClassesRoot.Op
View Complete Post