ASP.NET MVC html page authentication

I have some static (pure html) pages in my MVC application that I need for authentication so that not only someone can see them. Is there a way to do this without moving all the code to asp files and adding a controller, and from there use the Authorize attribute? I would rather not do it!

+3
source share
2 answers

If these static HTML pages are in a separate folder, you can configure IIS and Windows Folder security using IIS Admin.

You can also see role-based security , however I'm not sure if this will work for static HTML files (not .aspx).

0
source

I looked at role-based security, and I found that adding

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

the web.config file worked like a charm! It blocks all users who are not logged in to the website.

+2
source

Source: https://habr.com/ru/post/1757380/


All Articles