Search code examples
asp.netasp.net-mvc-4asp.net-membershipmembership-provider

Disabling Membership in ASP.NET is not working


I am maintaining an existing asp.net website. I do not completely understand the project because another developer just handed it to me. Project is not neat. .NET version is 4 and MVC version is 4 as well. Now, I need to completely disable the membership system of the project. I found a lot of article and some changes need to be done in web.config.

I added this lines in web.config

<system.web>
    <membership>
  <providers>
    <clear/>
  </providers>
</membership> 

When I run application, it throws this error.

enter image description here

So then I tried this instead

<membership>
    <providers>
        <clear />       
    </providers>
</membership>
<roleManager enabled="false">
    <providers>
        <clear />       
    </providers>
</roleManager>
<profile>
    <providers>
        <clear />       
    </providers>
</profile>

Then I gave me this error

enter image description here

How can I completely disable membership in asp.net?


Solution

  • Removing Membership Provider is easy. You just comment out the following 3 tags inside web.config

    <system.web>    
        <!--<membership>...</membership>-->
        <!--<roleManager enabled="true">...</roleManager>-->
        <!--<profile>...</profile>-->
    </system.web>    
    

    The main question is after removing, how do you plan to authenticate and authorize a user.

    If you do not need authentication and allow anonymous access, you'll still need to remove [Authorize] attribute on each controller and action methods, or global filter.