Lock files in Asp.net mvc folder

Asked

Viewed 241 times

5

I have a folder named "app" I want to block access to all files if the user is not logged in.

tried so:

<location path="app">
  <system.web>
     <authorization>
        <deny users="?"/>
     </authorization>
  </system.web>
</location>

but if I access /app/somethings.Xyz it accesses...

  • Have you tried "~/app"?

  • already, I can still access the file...

  • put this part you put in the question above the <system.web> web.config, i.e., at the beginning of the file.

  • also not...

1 answer

3


It remains to warn the IIS that any and all requests (including static files) must be processed by it. The way it was before, the OSI doesn’t apply the FormsAuthentication about static files.

Put it in your file Web.config the following:

<configuration>
    ...
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
    ...
</configuration>
  • worked =D only removes <modules> <remove name="Formsauthentication" /> </modules> from within, and worked well, no problem right

  • @Rod that there. In fact you have correctly enabled the FormsAuthentication. It should work OK.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.