Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a logging off function in my application. but it does not work correctly.
So i tried for last two days to do that. but i couldn't. \

This is the link to Action
------------------------------
<a href="@Url.Action("LogOut","Account")" class="cc-font-min">Log off</a></p>


This is the my Action for that
---------------------------------

C#
public ActionResult LogOut()
{
    Session.Clear();
    WebSecurity.Logout();
    return RedirectToAction("Index", "Home");
}


And also this is the error that is follow me always. :)

To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider".


This is the part of my web.config file
------------------------------
XML
   <appSettings>
  <add key="webpages:Version" value="2.0.0.0" />
  <add key="webpages:Enabled" value="false" />
  <add key="InboxPath" value="C:\test" />
  <add key="UploadPath" value="C:\uploaded" />
  <add key="UploadPathV" value="http://localhost/pn/uploaded"/>
  <add key="creditorFolders" value="test" />
  <add key="PreserveLoginUrl" value="true" />
  <add key="ClientValidationEnabled" value="true" />
  <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <roleManager enabled="true" />
  <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="60">
    <providers>
      <clear />
      <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" connectionStringName="USCP" applicationName="CreditorPortal" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" />
    </providers>
  </membership>
  <httpRuntime targetFramework="4.5" maxRequestLength="1048576" />
  <authentication mode="Forms">
    <forms loginUrl="~/Account/Login" timeout="2880" />
  </authentication>
  <pages>
    <namespaces>
      <add namespace="System.Web.Helpers" />
      <add namespace="System.Web.Mvc" />
      <add namespace="System.Web.Mvc.Ajax" />
      <add namespace="System.Web.Mvc.Html" />
      <add namespace="System.Web.Optimization" />
      <add namespace="System.Web.Routing" />
      <add namespace="System.Web.WebPages" />
    </namespaces>
  </pages>
</system.web>
<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <handlers>
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  </handlers>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="1048576000" />
    </requestFiltering>
  </security>
</system.webServer>
Posted
Comments
Sinisa Hajnal 18-Jun-15 4:05am    
And the error pops up on WebSecurity.Logout call? You should look into it, set the property as required.

Also, you might consider calling Session.Abandon after (or insted of) .Clear.
Member 11670657 18-Jun-15 5:06am    
yes. error comes when call WebSecurity.Logout.
What are the required property?
Sinisa Hajnal 18-Jun-15 6:20am    
Required means that you have to provide the value for the method to work. The error says you need to set Membership.Provider to an instance of ExtendedMembershipProvider.
Sreekanth Mothukuru 18-Jun-15 4:30am    
I guess your application accepts Facebook, Google and Microsoft accounts to login and that is the reason it is showing "ExtendedMembershipProvider"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900