6

I have issue with my app after run it on VPS.

I installed IIS on VPS, removed DefaultWebsite, and add another one. Everything looks fine, website starts, but I don't have access to any files from folders like Content, Scripts, Templates and so on. That's mean i don't have any pictures, and styles on my website.

I try to grand permissions for IIS_IUSRS but files still don't display correctly. Website is on on same partition as system, and i think that's the problem, but i can't move it. I have just one partition :-( Any solution for it?

Michal
  • 71
  • 1
  • 1
  • 3

7 Answers7

5

None of the above worked for me. What did work (and I remember from eons gone by) is the lack of a MIME type mapping confuses IIS. This is easy to diagnose as the problem if you can put files of different types in different folders.

Easy fix is the "MIME Types" section under IIS, either on the server, web site, or virtual folder. Just add "*.foo" and "application/octet-stream" as the MIME type which says "just send the bytes already!"

Eliot Gillum
  • 832
  • 9
  • 18
  • This is the solution that worked for me. I set my content type to application/octet-stream, and IIS served the file. – sevenr Apr 01 '22 at 00:07
  • 1
    A quick though very insecure fix to ensure that IIS serves so far unconfigured MIME types as "application/octet-stream" is to add a default MIME type in the config as detailed at https://stackoverflow.com/a/8717569/1974403. Remember though that this will make IIS serve every unrecognized type as an octet stream, leading to possible security compromises. – sevenr Apr 01 '22 at 01:54
1

You need to add a web.config file to serve static files in each folder that contains static files with the following content:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
        </staticContent>
        <handlers accessPolicy="Script,Read">
            <!-- For any request to a file exists on disk, return it via native http module. AccessPolicy="Script" above is to allow for a managed 404 page. -->
            <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
        </handlers>
    </system.webServer>
</configuration>
0

Please check user in IIS. Site -> Basic Settings -> Connect as... (if I recall correctly)

By default user in IIS is IUSR. You have to change to IIS_IUSRS. And then Your permissions will work.

This Article could help you

SouXin
  • 1,565
  • 11
  • 17
0

I also have add this code to make app running. Without it app don't work, but files show correctly :-(

<system.webServer>
   <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
   <remove name="BlockViewHandler"/>
     <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
    </handlers>
    </system.webServer>
Michal
  • 71
  • 1
  • 1
  • 3
0

In my case, I had a file with the extension cache - an unknown mime type within IIS.

My 404 file not found trouble was resolved by updating the site web.config to add mimeMap for file extension cache, as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="true" />
        <security>
            <requestFiltering>
                <fileExtensions>
                    <remove fileExtension=".config" />
                    <add fileExtension=".config" allowed="true" />
                    <add fileExtension=".dll" allowed="true" />
                    <add fileExtension=".exe" allowed="true" />
                </fileExtensions>
            </requestFiltering>
        </security>
        <handlers accessPolicy="Read, Script" />
        <staticContent>
            <mimeMap fileExtension=".cache" mimeType="text/plain" />
        </staticContent>
    </system.webServer>
</configuration>

More about Adding Static Content MIME Mappings and Troublshooting a 404

Adam Cox
  • 3,341
  • 1
  • 36
  • 46
0

Probably not a common problem, but I accidentally created a virtual directory with the path to my default page, and that messed things up. I had to open the applicationhost.config file, and delete the virtual directory (well, probably could have deleted it another way, but I didn't figure it out until I opened the file, and since I already had it open, I went ahead and saved the changes).

jmoreno
  • 12,752
  • 4
  • 60
  • 91
0

I also had this problem, it turned out to be file path problem.

I tried to access the path as "C:\folder\file"

When i tried to access it as "\file" it worked, so it is going to be like "(your server)\file"

Not "(your server)C:\folder\file"