We Help You To Renovate Your Blogger Blog With Awesomeness!

Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

Saturday, December 6, 2014

  • Prepare web.config for HTML5 and CSS3 HTTP Error 404.3 - Not Found

    HTTP Error 404.3 - Not Found
    The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
    The problem is that the IIS doesn’t know how to serve these new files unless we tell it how. This can be easily done in the web.config’s <system.webServer> section by adding the following snippet:
     
     
    <staticContent>
        <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
        <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
        <mimeMap fileExtension=".ogg" mimeType="video/ogg" />
        <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
        <mimeMap fileExtension=".webm" mimeType="video/webm" />
    
        <mimeMap fileExtension=".oga" mimeType="audio/ogg" />
        <mimeMap fileExtension=".spx" mimeType="audio/ogg" />
    
        <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
        <mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
    
        <remove fileExtension=".eot" />
        <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
        <mimeMap fileExtension=".otf" mimeType="font/otf" />
        <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
    </staticContent>
     
     
    The above snippet incl

    udes support for most video, audio and font file types used by HTML5 and CSS3.
  • Wednesday, October 1, 2014

  • Read HTML File C# ASP Stream Reader



    string file = Server.MapPath ("abc.html");
    StreamReader sr;
    FileInfo fi = new FileInfo(file);
    if(File.Exists(file))
    {
         sr = File.OpenText(file);
         input += sr.ReadToEnd();
         sr.Close();
    }
     
     
     
     
     

    Another Method 

     

    string[] lines = File.ReadAllLines("path/to/my/file.html");
    foreach(string line in lines)
    {
        Response.Write(line);
    }

     

     
     
     
     
     
  • Saturday, September 20, 2014

  • How to set read write permission to directory in C#.NET

    While working with files and directory we need read write permission on files and folders, this can be done by manually giving access permission to directory as well as programmatically.


    private static void SetPermissions(string dirPath)
    {
        DirectoryInfo info = new DirectoryInfo(dirPath);
        WindowsIdentity self = System.Security.Principal.WindowsIdentity.GetCurrent();
        DirectorySecurity ds = info.GetAccessControl();
        ds.AddAccessRule(new FileSystemAccessRule(self.Name,
        FileSystemRights.FullControl,
        InheritanceFlags.ObjectInherit |
        InheritanceFlags.ContainerInherit,
        PropagationFlags.None,
        AccessControlType.Allow));
        info.SetAccessControl(ds);
    }

     read-only on access on file
    FileInfo myFile = new FileInfo(files.FullName);
    myFile.IsReadOnly = false;
      File with Read Write permission

    FileStream F = new FileStream("test.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite);

  • Copyright @ 2013 Code Snippets.