When testing usercontrols I test them outside Umbraco (unless using the API) by copying the database connection from the Umbraco site, creating a standard .NET page and then include the usercontrol within that, I can then debug that user control within Visual Studio as usual.
Essentially it's just a standard web app as you're not using Umbraco functionality in your above code.
Set that up and you should see your error pretty quickly?
Are you sure you're logged on, GetMember will only return a member object if logged on! And btw, you should be using the membership provider api over the existing member api. Details may be found on the wiki pages.
As you can see im trying to add the member to the log when he has logged in but the Identity.Name is empty. Why is that? I know im logged in because the page is only visible to logged in members!
Using existing DB connection
Ive created a table in the db where I want to store information when members is logged in so that I can display that in the back.
How do I get the db connection from my Usercontrol? Ive tried to use the Mysql.Data as reference but then it complains about wrong reference..
You can use the connection string from the Web.Config file.
Include a a reference to:
Then something like this
Hope this helps.
Rich
Hi,
You could also use the
object (only to use if you're using the same umbraco database to store the info about member visits)
Cheers,
/Dirk
Perfect!
But I get an error: Keyword datalayer not supported.
This may help debugging
When testing usercontrols I test them outside Umbraco (unless using the API) by copying the database connection from the Umbraco site, creating a standard .NET page and then include the usercontrol within that, I can then debug that user control within Visual Studio as usual.
Essentially it's just a standard web app as you're not using Umbraco functionality in your above code.
Set that up and you should see your error pretty quickly?
I think the problem is that the connectionstring includes datalayer. Can that be it? And how do I work around it? Do I have to add a new key myself?
Try removing the "datalayer" part of your connection string.
Or use the SqlHelper, it's designed to not worry about the datalayer part of the connection string!
Cheers,
/Dirk
And how do I use the SqlHelper..?
froad,
Have a look at the msdn docs on http://umbraco.org/apiDocs/index.html
ISqlHelper can be found in the umbraco.DataLayer namespace.
Cheers,
/Dirk
Made it work..Thanks!
Next problem...how do I get the current member? I tried following:
But that didnt fetch anything..
froad,
Are you sure you're logged on, GetMember will only return a member object if logged on! And btw, you should be using the membership provider api over the existing member api. Details may be found on the wiki pages.
Cheers,
/Dirk
Sorry to overwhelm you with questions before diggin in myself...
Solved it this way:
Thank you for your time and advices!
Returning because it didnt work..
As you can see im trying to add the member to the log when he has logged in but the Identity.Name is empty. Why is that? I know im logged in because the page is only visible to logged in members!
Solved it in ´the not best way:
Why go for the cache when I had the answer in the login-control all the time :)
is working on a reply...