Dane W
Dane W

Reputation: 408

.NET MVC 4 Membership.CreateUser() Security Exception Forms Authentication

I am getting the following error at this line of code...

MembershipUser newuser = Membership.CreateUser(usersvm.username, usersvm.password,
                usersvm.email, null, null, true, null, out createStatus);

The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

[SecurityException: The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.]

I also have this in the web.config file

  <system.web>
     <trust level="Full"/>

Here is some stack trace

MySql.Web.Security.MySQLMembershipProvider.WriteToEventLog(Exception e, String action) +380
System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) +207
System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, MembershipCreateStatus& status) +26

Upvotes: 0

Views: 1231

Answers (1)

Dane W
Dane W

Reputation: 408

I needed to add this writeExceptionsToEventLog = "false" in web.config like this

<membership defaultProvider="MySQLMembershipProvider">
   <providers>
      <remove name="MySQLMembershipProvider"/>
           <add autogenerateschema="true" writeExceptionsToEventLog="false" ....

Upvotes: 2

Related Questions