ASP.NET Forms Authenticated Routing in Web Forms

I am working on an ASP.NET Web Forms Application that uses Forms Authentication. The problem is it ignores my route and redirects to the login.aspx page.

I have the following route setup:

routes.MapPageRoute("/locale", "{locale}", "~/shorturl/transfer.aspx", 
            false, 
            new RouteValueDictionary { { "locale", "[a-z]{2}" } });

      

If I use the following URL: http: // server / minneapolis it goes to the login page. If I add the following to the Web.Config, then it "works" and goes to the transfer.aspx page.

<location path="minneapolis"> 
    <system.web> 
      <authorization> 
        <allow users="*"/> 
      </authorization> 
    </system.web> 
 </location>

      

I don't want to add all the locales to the web.config, it seems to defeat the purpose.

I can also change the route (note that I added "/ loc /"):

    routes.MapPageRoute("/locale", "/loc/{locale}", "~/shorturl/transfer.aspx", 
            false, 
            new RouteValueDictionary { { "locale", "[a-z]{2}" } });

      

After that, I can change the Web.Config location path to loc (location path = "loc") and it works, but I'd rather have it in the root. Is there a way to do this?

This is .NET v4 and I have to support IIS 7 and IIS 7.5

+3


source to share


1 answer


I don't think there is a way to do this. Authorization is URL-based, and the authorization module appears to be checking the source URL , not the recipient's URL, when it determines how to authorize the request.

As with 6 months, exactly the same as in one of my projects. I got the solution you suggest - my routed requests were placed in a "subfolder" and I created a local one web.config

with authorization allow users=*

.



If there is a way around this, I would also like to hear how this should be done.

0


source







All Articles