How to enable case-sensitivity under IIS Express?

后端 未结 2 1685
耶瑟儿~
耶瑟儿~ 2020-12-18 01:13

How should I go about enabling case sensitive request handling if using IIS Express? Is there a setting in IIS Express? or can a URL Rewrite rule accomplish this? or perhaps

相关标签:
2条回答
  • 2020-12-18 01:41

    IIS is case-sensitive...

    ...but not for files.

    It is a misnomer that IIS is case-insensitive, it is the Windows file system that is case-insensitive, not IIS. If a URL contains a file path then IIS asks Windows if the file exists and the OS responds without regard to letter case. There is no way to "enable" case sensitivity for file names in Windows.

    But for other than real file paths, IIS is 100% case-sensitive. The case of URL characters is passed to the IIS pipeline intact. It is up to the web application whether or not case-sensitivity exists. But good practice says you don't want /page1 to be different than /PAGE1.

    ASP.NET is case-insensitive to query string variable names. AGAIN, this is not IIS. It is the application (ASP.NET) that is case-insensitive.

    Summary

    Static file paths are not case-sensitive (due to Windows OS, not IIS):

    http://example.com/sUbdiRectoRy/FILe.aspx
    

    HOWEVER, portions of the URL not participating in the file path are case-sensitive (everything after file.aspx below except for the 'x' parameter because .aspx is an ASP.NET resource):

    http://example.com/sUbdiRectoRy/FILe.aspx/Extra/Tail?x="query parameter"
    

    URLs that are dynamically generated by re-writes, HttpModules, etc. are also case-sensitive if the application is case-sensitive. This is usually not best practice as these two URLs would refer to two separate web pages:

    http://example.com/2012/01/23/blog-article
    http://example.com/2012/01/23/BLOG-ARTICLE
    
    0 讨论(0)
  • 2020-12-18 01:41

    As already pointed out by Kevin Rice, this has nothing to do with IIS.
    This is all about the file system, the file-system driver and the operating system / asp.net.

    The default file-system for Windows 2000+ is NTFS, which is case-insensitive. What you need is a case-sensitive file system, so you should look for a file system driver for windows that is case-sensitive.

    The usual default Linux file-systems (called ext2/ext3/ext4) are all case-sensitive. And you can find a windows driver for them here: http://www.ext2fsd.com/

    All you need to do is to put your application on that file-system, and configure IIS to start the application from there (you might want to dual-boot install Linux so you actually do have a ext4 partition on that computer - be careful, if you do that wrong, your data may be GONE).

    What would bother me more is why the S3 file system is case-sensitive.
    That is a very bad thing, if somebody mistypes your URL, or if a search-engine lowercases it, you get a 404...

    May I suggest that instead of looking how you can get windows to be case-sensitive, you look how you can get S3 to become case-insensitive, that's probably the better approach.

    I don't actually know how to do that on S3 since I don't know S3.
    What I do know however is Linux (which Amazon S3 is probably using), so if you can make your own file system, at the bottom of my post here you find (commented out) ways of doing this.

    In a nutshell, you create a .dsk file of wanted size X bytes (X = count * blocksize) format it with a case-insensitive file-system (vfat, jsf, hfsplus) and loopmount it to /mnt/whatever.

    Then you put your web application in /mnt/whatever, and configure the root directory for the web-application to be there.

    Note that if you omit -O in JFS, it will be case-sensitive.

    apt-get install jfsutils
    dd if=/dev/zero of=jfs.dsk bs=1048576 count=150
    mkfs.jfs -O jfs.dsk
    mkdir -p /mnt/jfs
    mount /volumes/jfs.dsk /mnt/jfs -t jfs -o loop
    umount /mnt/jfs/
    

    or like this with hfs-plus (best performance, HFS: high-performance file-system)

    sudo apt-get install hfsprogs
    sudo modprobe hfsplus
    sudo dd if=/dev/zero of=hfsplus.dsk bs=1048576 count=150
    sudo mkfs.hfsplus /volumes/hfsplus.dsk
    sudo mount /volumes/hfsplus.dsk /mnt/hfsplus -t hfsplus -o loop
    umount /mnt/hfsplus/
    

    Also, if you don't want to (or can't) install anything, vfat is usually installed by default:

    mkfs -T vfat /volumes/vfat.dsk
    

    Also, Red-Hat derived Distributions of Linux (like S3) don't use apt-get, they use rpm/yum.

    And, if you want the filesystem to be permanently mounted, you need to add the entry to /etc/fstab more on it here: https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Introduction_To_System_Administration/s2-storage-mount-fstab.html

    or you can add a startup script that mounts this particular file system on every system restart/boot.

    0 讨论(0)
提交回复
热议问题