<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>DotNetNuke</title><link>http://www.dotnetnuke.com/tabid/795/Default.aspx</link><description>Discussions of DotNetNuke for ASP.NET 1.x and above.  &lt;a href="http://www.dotnetnuke.com/" target="_blank"&gt;DNN Home&lt;/a&gt; &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=105&amp;c=25" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Using UserController from Outside HttpContext</title><link>http://forums.asp.net/thread/1108368.aspx</link><pubDate>Thu, 10 Nov 2005 03:41:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1108368</guid><dc:creator>xzg3</dc:creator><author>xzg3</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1108368.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=90&amp;PostID=1108368</wfw:commentRss><description>Hey Brendan, I'd like to know more about this too. Decoupling the DNN core from HTTPContext seems like a good thing to me....&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Josh&lt;br&gt;
&lt;br&gt;</description></item><item><title>Re: Using UserController from Outside HttpContext</title><link>http://forums.asp.net/thread/1053682.aspx</link><pubDate>Thu, 15 Sep 2005 22:37:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1053682</guid><dc:creator>brendanrichards</dc:creator><author>brendanrichards</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1053682.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=90&amp;PostID=1053682</wfw:commentRss><description>As far as I can tell a user only ever belongs to&amp;nbsp;one portal (Except the superuser)&amp;nbsp;- a user's portal id is stored in UserInfo.PortalId.&lt;BR&gt;&lt;BR&gt;</description></item><item><title>Re: Using UserController from Outside HttpContext</title><link>http://forums.asp.net/thread/1052637.aspx</link><pubDate>Thu, 15 Sep 2005 07:54:38 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1052637</guid><dc:creator>rodneyjoyce</dc:creator><author>rodneyjoyce</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1052637.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=90&amp;PostID=1052637</wfw:commentRss><description>Thanks for sharing Brendan.&lt;br&gt;
&lt;br&gt;
My knowledge of this area is a bit sparse - I use the scheduler to send
out birthday emails for my UserProfile module - can you explain how the
scheduler will know what Portal a user belongs to? Does your code
handle multiple portals?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;</description></item><item><title>Using UserController from Outside HttpContext</title><link>http://forums.asp.net/thread/1052546.aspx</link><pubDate>Thu, 15 Sep 2005 05:20:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1052546</guid><dc:creator>brendanrichards</dc:creator><author>brendanrichards</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1052546.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=90&amp;PostID=1052546</wfw:commentRss><description>Hi, &lt;br&gt;
&lt;br&gt;
I've had a specific problem with the UserController / DNNMembership
provider code which I've found a work-around to so I'm posting my
solution in case anyone else finds it useful or can point out any
problems in my thinking...&lt;br&gt;
&lt;br&gt;
First a bit of background:&lt;br&gt;
&lt;br&gt;
My website solution using DotNetNuke required an daily user-import
process to import users from external data. This process runs under the
DNN webapp within its own Thread so that&amp;nbsp; you can set it running
via a web interface but not have to wait for it to complete before
viewing the next screen (which in this case is a little web control
that displays a progress report for the running import process).&lt;br&gt;
&lt;br&gt;
The problem with this approach was that DNNSQLMembership provider (and
other similar providers such as DNNSQLRoleProvider etc) use the
HTTPContext.Current object to store an "ApplicationName" property:&lt;br&gt;
&lt;br&gt;
&lt;font color="#0000ff" face="Arial" size="2"&gt;HttpContext.Current.Items("ApplicationName") = ApplicationName&lt;/font&gt;&lt;br&gt;
&lt;br&gt;
When called from a Thread other than within a Request/Response,
HTTPContext.Current is null which meant that the UserController.AddUser
was throwing a null object exception when called from my import process
Thread.&lt;br&gt;
&lt;br&gt;
My fix is to add a null-check and then use a "ThreadLocal " [java terminology ;-) ] property if HTTPContext.Current is null&lt;br&gt;
&lt;br&gt;
So the Set function of DNNSQLProvider.ApplicationName() becomes:&lt;br&gt;
&lt;br&gt;
&lt;font color="#0000ff" face="Arial" size="2"&gt;Set(ByVal Value As String)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
If (HttpContext.Current Is Nothing) Then&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
System.Threading.Thread.SetData(System.Threading.Thread.GetNamedDataSlot("ApplicationName"),
ApplicationName)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
HttpContext.Current.Items("ApplicationName") = ApplicationName&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br&gt;
End Set&lt;/font&gt;&lt;br&gt;
&lt;br&gt;
This works by attaching the value to the local Thread rather than HTTPContext. &lt;br&gt;
I applied this approach wherever I found &lt;font color="#0000ff" face="Arial" size="2"&gt;HttpContext.Current.Items("ApplicationName") &lt;font color="#000000"&gt;in the DNN Solution and can now modify users from my Thread.&lt;br&gt;
&lt;br&gt;
I suspect this fix may be useful to anyone who intends to modify users from the DNNScheduler.&lt;br&gt;
&lt;br&gt;
hope someone finds this useful - If so, I can provide more details...&lt;br&gt;
&lt;br&gt;
Brendan. &lt;br&gt;
&lt;/font&gt;&lt;/font&gt;</description></item></channel></rss>