5

I have a folder in my web site for which I secured with forms-based authentication. I now have to develop two new pages in that folder and I want to turn security off while I test and debug the new forms. I have changed the authentication mode in the web site's web.config file to mode="None" and I have removed the web.config file from the secured folder. I have deleted all the cookies in my browser, but when I go to load a page from this folder, I still am re-routed to the login page.

How do I temporarily disable forms authentication in a web site?

9/25/2009 - I have set forms authentication = "None" in the root web.config file. I have removed the web.config files from the two sub-folders where forms authentication had been implemented. I cleared the cache and deleted the cookies. Still I am asked to login to view a page in the folder. I navigated to the page on a machine that had never been there before and was asked to login there. This is being cached somewhere in the web site on the server that won't let go.

8 Answers 8

6

Try adding the information below to your web.config. This will remove the items in the path from the authorization required.

<location path="XXXXXXXXX">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
Sign up to request clarification or add additional context in comments.

1 Comment

I tried this and no joy. I tried again with no path attribute which MSDN says will apply to the current directory and all child directories and still no joy. I tried adding users="?" also and still no joy.
2

You can use the location tag in the web.config for that secured directory to overidde security for those pages:

 <location path="secureddir/newform.aspx">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx

Comments

1

You may have a page (or a base class, or a master page) that is calling FormsAuthentication.RedirectToLoginPage();

1 Comment

All of my authentication redirection is begin done with web.config files. The only redirect is from the Logout.aspx page. There is nothing in any class or master page having to do with security.
1

I wanted to be able to disable authentication throughout the app while debugging so I did the following:

1) Created this class.

namespace System.Web.Mvc
{
    public class SwitchableAuthorizeAttribute : AuthorizeAttribute
    {
        public static bool Enabled = true;

        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (Enabled)
            {
                base.OnAuthorization(filterContext);
            }
        }
    }
}

2) Replaced the [Authorize] attribute with [SwitchableAuthorize] throughout the application.

3) Turned authorization off when desired. For example, I added the following to App_Start/AuthConfig.cs:

public static class AuthConfig
{
    public static void RegisterAuth()
    {
        #if DEBUG
        SwitchableAuthorizeAttribute = false;
        #endif

        ...           
    }
}

You may have conditions other than DEBUG. This approach will allow you to programmatically turn authorization on/off at any time.

If your pages require logged in User information, this method could be enhanced by performing some bogus login rather than simply skipping base.OnAuthorization().

Comments

0

turning the authenticode to none should do it. there must be something you're missing, are you sure you're browsing the deployed code that you updated?

1 Comment

I am sure I am missing something. That is why I posted the question
0

I've had this problem before - this may not pertain to you, but I'll mention that it was an in-memory cookie that caused my authentication form to keep coming up. I found out by trying a different browser, that is, FF, Chrome, instead of IE.

6 Comments

I am using FireFox as the default. I just tried opening one of the pages in IE using the development server IIS instead of localhost. Still no joy.
Perhaps there is an intermediate config file between the root and secured folder? Or the web.config file points to another config file for authentication: <authentication configSource="webAuthentication.config"/> Or the machine.config authentication section is somehow being used? Or there's some custom authentication going on in global.asax?
The only thing in Global.asx is a trap for a 404 error. No configSource in web.config. To my knowledge no one has ever touched machine.config so it should be in pristine default condition. There are only three web.config files—one in the root, one in the Secure folder where I put all the login and user management pages and one in the folder that contains the content that needs secure access. Are you saying that the web.config file in one folder can impact the behavior of a peer folder? That would be nasty. - pamela
Did you try stopping and restarting the webserver? Are you using IIS7? There's a forms authentication setting in iis Manager. A debug session starting with app_start didn't show you anything?
@Steve My IIS management skills are kind of thin. But I get the same results in the VS server on localhost that I do on the server for the development site. We have given IUSER anonymous access for the site and there is no problem accesssing folders that were never put under forms authentication. Just the ones that were. If I put a breakpoint in App_Start, what would I be looking for?
|
0

try removing mode="XXXX" from authentication node and also comment authorization node

Comments

0

This is an extremely old post but I just had a similar issue and wanted to share my solution.

IIS Manager -> Authentication:

Ensure 'Forms Authentication', 'Windows Authentication', etc. are set to 'Disabled'

Set 'Anonymous Authentication' to 'Enabled'

This will allow the client to passthrough to the application's authentication methods defined in your code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.