Anonymous access in MVC 5

413 Views Asked by At

How to allow anonymous access in routeconfig in asp.net mvc 5 ?

In routeconfig I've added:

routes.MapRoute(
name:"cert",
url:".well-known/acme-challenge")

I want to allow anonymous access to mydomain.com/.well-known/*

2

There are 2 best solutions below

0
On

I found one solution. I have 2 folders named Monitoring & Resources in web layer and I put this code in my web.config and this will work for me

<location path="Monitoring">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>
<location path="Resources">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>
2
On

Just put the tag [AllowAnonymous] on top of the function in your controller you want to allow anonymous access