Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Security / October 2007

Tip: Looking for answers? Try searching our database.

How To Add User's GUID To An Account Verification E-mail

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonathan Gill - 28 Oct 2007 02:37 GMT
Hi everyone,
So I have a problem that is more difficult that it might seem at first
glance.  created.  Any help/a clever "duh" answer would be great as we've
spent more than 8 hours trying to get this working.

Please see the following thread for the full details:

"How To Add User's GUID To An Account Verification E-mail - E-mail Working,
Error In Retreiving GUID"

http://forums.asp.net/p/1172523

----
am receiving an error when I try to retrieve a newly (and
successfully...checked the DB) registered users GUID to include in an account
verification e-mail.  I am using the e-mail that is sent by the membership
provider, however I am adding an extra step for the user to verify their
account.  The e-mail works fine as long as I don't try and use the user's
GUID.  The verification of a user's account step uses a newly defined
placeholder (<% Username %> and <% Password %> are supported by default in
asp.net membership) in the .txt file that is the basis for the e-mail.  I can
get the placeholder to replace fine in the e-mail, however I get an error
when I try to include the user's GUID in the e-mail.

Here are examples:
http://www.pcw.co.uk/personal-computer-world/features/2153686/membership-rules?page=3,
http://dotnetjunkies.com/WebLog/saravana/archive/2006/04/30/137645.aspx

Any help with fixing the error is appreciated.  Thanks!  

 

Error

System.NullReferenceException was unhandled by user code
 Message="Object reference not set to an instance of an object."
 Source="App_Web_rih02pg9"
 StackTrace:
      at signup.CreateUserWizard1_SendingMail(Object sender,
MailMessageEventArgs e) in C:\Documents and Settings\Owner\My
Documents\Visual Studio 2005\WebSites\Test\Signup.aspx.vb:line 81
      at
System.Web.UI.WebControls.CreateUserWizard.OnSendingMail(MailMessageEventArgs
e)
      at System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email,
String userName, String password, MailDefinition mailDefinition, String
defaultSubject, String defaultBody, OnSendingMailDelegate
onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate,
Control owner)

    Protected Sub CreateUserWizard1_SendingMail(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles
CreateUserWizard1.SendingMail
       Dim tempMem As MembershipUser =
Membership.GetUser(CreateUserWizard1.UserName)

       'Replace placeholder for the verification URL
       e.Message.Body = Replace(e.Message.Body, "<% VerifyURL %>",
"http://www.test.com/VerifyAccount.aspx?key=" &
tempMem.ProviderUserKey.ToString) ' Error occurs on this line
    'Line below will work and replace the placeholder in the e-mail file        
'e.Message.Body = e.Message.Body.Replace("<% VerifyURL %>",
"http://www.test.com/VerifyAccount.aspx?key=123)

   End Sub    Protected Sub CreateUserWizard1_SendingMail(ByVal sender As
Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles
CreateUserWizard1.SendingMail
       Dim tempMem As MembershipUser =
Membership.GetUser(CreateUserWizard1.UserName.ToString)
       MsgBox(tempMem.ProviderUserKey.ToString) ' Will return error here

       'Replace placeholder for the verification URL
       e.Message.Body = Replace(e.Message.Body, "<% VerifyURL %>",
"http://www.test.com/VerifyAccount.aspx?key=" &
tempMem.ProviderUserKey.ToString) ' Error occurs on this line
 'Line below will work and replace the placeholder in the e-mail file

       'e.Message.Body = e.Message.Body.Replace("<% VerifyURL %>",
"http://www.test.com/VerifyAccount.aspx?key=123)
   End Sub
Alexey Smirnov - 28 Oct 2007 09:31 GMT
On Oct 28, 2:37 am, Jonathan Gill
<JonathanG...@discussions.microsoft.com> wrote:
> http://forums.asp.net/p/1172523

Link doesn't work

> System.NullReferenceException was unhandled by user code
>   Message="Object reference not set to an instance of an object."

It means your GUID is null, try to check it before making a call.
Jonathan Gill - 28 Oct 2007 17:09 GMT
Yes, Membership.Getuser says the user is null, but it is not. If I set a
break point before I call Membership.GetUser in the CreatedUser event of the
CreateNewUserWizard or even inthe SendingMil event which fires after
CreatedUser then I can manully check the DB and see all of the user's details
saved.

> On Oct 28, 2:37 am, Jonathan Gill
> <JonathanG...@discussions.microsoft.com> wrote:
[quoted text clipped - 6 lines]
>
> It means your GUID is null, try to check it before making a call.
Alexey Smirnov - 29 Oct 2007 10:08 GMT
On Oct 28, 5:09 pm, Jonathan Gill
<JonathanG...@discussions.microsoft.com> wrote:
> Yes, Membership.Getuser says the user is null, but it is not. If I set a
> break point before I call Membership.GetUser in the CreatedUser event of the
[quoted text clipped - 14 lines]
>
> - Show quoted text -

What line is #81?
Jonathan Gill - 29 Oct 2007 13:54 GMT
Finally, determined the cause of the error.  The DB had two application IDs
while I specified the applicationName in the membership provider, I needed to
specify the applicationName that I was looking for users in.

> Hi everyone,
> So I have a problem that is more difficult that it might seem at first
[quoted text clipped - 76 lines]
> "http://www.test.com/VerifyAccount.aspx?key=123)
>     End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.