<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : throw Login exception</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : throw Login exception</description>
  <pubDate>Thu, 21 May 2026 21:26:34 -700</pubDate>
  <lastBuildDate>Sun, 24 Jan 2010 18:39:25 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=1623</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>throw Login exception : My apologies. For some reason...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1623&amp;PID=6124#6124</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1623<br /><strong>Posted:</strong> 24-Jan-2010 at 6:39pm<br /><br />My apologies.&nbsp; For some reason I thought you were using another sample application and had added&nbsp;a sample code snippet.&nbsp; <DIV>&nbsp;</DIV><DIV>What should happen is that the LoginException you throw is caught by DevForce and turned into a LoginFault to be sent to the Silverlight application.&nbsp; DevForce code in the Silverlight application then turns this fault back into a LoginException and tucks it into the LoginEventArgs.&nbsp; In the sample, a MessageBox will pop up with the exception message.</DIV><DIV>&nbsp;</DIV><DIV>When debugging in Visual Studio, VS will see this exception thrown and depending on your debugging options may stop you with the Exception Assistant.&nbsp;&nbsp; There are several ways around this:</DIV><UL><LI>&nbsp;Generally you can mark a type or member with the System.Diagnostics.DebuggerNonUserCode attribute to tell Visual Studio to ignore an exception thrown by your code.&nbsp; Unfortunately, if you add it to the code here the problem still persists, so we likely also forgot to mark up the base class.&nbsp; We'll open a bug report for this.</LI><LI>You can also have Visual Studio ignore this exception by adding&nbsp;"IdeaBlade.EntityModel.LoginException" to the Debug | Exceptions window.&nbsp; Add the exception to the "Common Language Runtime Exceptions" list, and un-check the User-unhandled check box.&nbsp; </LI><LI>You can also try out&nbsp;the LoginException functionality without the debugger (i.e., start without debugging).&nbsp; This will&nbsp;show you how your users will see the feature, but isn't very useful&nbsp;since you probably do want to debug.</LI></UL><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Sun, 24 Jan 2010 18:39:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1623&amp;PID=6124#6124</guid>
  </item> 
  <item>
   <title>throw Login exception : I am not explaining myself well.  The...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1623&amp;PID=6121#6121</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=660" rel="nofollow">BruceKu</a><br /><strong>Subject:</strong> 1623<br /><strong>Posted:</strong> 24-Jan-2010 at 3:45pm<br /><br />I am not explaining myself well.<DIV>&nbsp;</DIV><DIV>The code I entered in my last posting is straight out of your example. I have added no code to the example at all.</DIV><DIV>&nbsp;</DIV><DIV>It comes from directory ...IdeaBlade Devforce\Learning Resources\100_Security\Samples\300SLV\CodeCs\</DIV><DIV>ASPNet Membership with Registration</DIV><DIV>&nbsp;</DIV><DIV>It is part of the samples you installed on my C drive when DEvForce is being installed.</DIV><DIV>&nbsp;</DIV><DIV>The code&nbsp;caught the error and caused the following line to be executed </DIV><DIV>&nbsp;</DIV><DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2>throw</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>LoginException</FONT></FONT><FONT size=2>(</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>LoginExceptionType</FONT></FONT><FONT size=2>.InvalidPassword, </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Invalid password"</FONT></FONT><FONT size=2>);</DIV><P>}</P><DIV></DIV><DIV>What I am asking is what does this code generate as a result?</DIV><DIV>&nbsp;</DIV><DIV>I expected it to display a message on the 'View' and then exit normally.</DIV><DIV>&nbsp;</DIV><DIV>Instead there was no display and the unhandled exception function(of the runtime in VS2008)&nbsp;caught the error and </DIV><DIV>terminated the program by stopping the execution and displaying the VS2008 error block.</DIV><DIV>&nbsp;</DIV><DIV>I want to be able catch errors such as this and exit from the program normally. I expected this</DIV><DIV>code to do it and it didn't.</DIV><DIV>&nbsp;</DIV><DIV>My question is how do I catch the error and exit using my own code for a normal program shutdown.</DIV><DIV>&nbsp;</DIV><DIV>A wrong password should not cause the program to exit abnormally. It is.</DIV><DIV>&nbsp;</DIV><DIV>As this is one of your examples I am hoping you understand this code better than me.</DIV><DIV>&nbsp;</DIV><DIV>Hope that makes my question clearer.</DIV><DIV>&nbsp;</DIV><DIV>Bruce</FONT></DIV>]]>
   </description>
   <pubDate>Sun, 24 Jan 2010 15:45:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1623&amp;PID=6121#6121</guid>
  </item> 
  <item>
   <title>throw Login exception : If you&amp;#039;ve added the code...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1623&amp;PID=6114#6114</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1623<br /><strong>Posted:</strong> 23-Jan-2010 at 5:35pm<br /><br /><FONT size=2 face="Arial, Helvetica, sans-serif">If you've added the code above to the sample "ASP.NET Membership and Roles" application, then you should see the LoginException returned in the LoginEventArgs when the login completes. </FONT><DIV>&nbsp;</DIV><DIV><DIV></DIV><DIV></DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>_entityManager.LoginAsync(credential, LoginCompleted, </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>null</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>);</FONT></FONT></DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas></FONT></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>private</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>void</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> LoginCompleted(</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>LoginEventArgs</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> args) {</FONT></FONT></DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; if</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> (args.Error != </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>null</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// args.Error will be the LoginException</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&nbsp;&nbsp;&nbsp; string errMessage = args.Error.Message;&nbsp;&nbsp; // This will contain the&nbsp;exception message</FONT></FONT></DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp;&nbsp;&nbsp; return</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>;</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&nbsp;&nbsp;}</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas>}</FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas></FONT></FONT>&nbsp;</DIV><DIV><FONT face=C&#111;nsolas><FONT face=C&#111;nsolas><FONT size=2 face="Arial, Helvetica, sans-serif">I'm not sure what you mean by the Unhandled Exception function ... but you should always check the Error property on the return arguments of any async call before trying to access the result.&nbsp; If the LoginEventArgs provided to your Login handler doesn't contain the exception please let us know, or post additional code so we can diagnose the problem.</FONT></DIV></FONT></FONT>]]>
   </description>
   <pubDate>Sat, 23 Jan 2010 17:35:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1623&amp;PID=6114#6114</guid>
  </item> 
  <item>
   <title>throw Login exception : I am running your ASPAuthentication...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1623&amp;PID=6108#6108</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=660" rel="nofollow">BruceKu</a><br /><strong>Subject:</strong> 1623<br /><strong>Posted:</strong> 22-Jan-2010 at 1:08pm<br /><br />I am running your ASPAuthentication sample.<DIV>I entered an incorrect password and in the following&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; code</DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2><P>protected</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>override</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>bool</FONT></FONT><FONT size=2> ValidateUserCore(</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>ILoginCredential</FONT></FONT><FONT size=2> credential) {</P><P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Base class calls Membership.ValidateUser, and returns t/f based on whether</P></FONT></FONT><FONT size=2><P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// the user is authenticated. If not authenticated, we don't actually know why.</P></FONT></FONT><FONT size=2><P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// The base class does not throw a LoginException if the user is not authenticated,</P></FONT></FONT><FONT size=2><P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// so we do here.</P></FONT></FONT><FONT size=2><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>bool</FONT></FONT><FONT size=2> isAuthenticated = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>base</FONT></FONT><FONT size=2>.ValidateUserCore(credential);</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (isAuthenticated) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> isAuthenticated;</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>var</FONT></FONT><FONT size=2> members = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Membership</FONT></FONT><FONT size=2>.FindUsersByName(credential.UserName);</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (members.Count == 0) {</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>throw</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>LoginException</FONT></FONT><FONT size=2>(</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>LoginExceptionType</FONT></FONT><FONT size=2>.InvalidUserName, </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Invalid username"</FONT></FONT><FONT size=2>);</P><P>} </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>else</FONT></FONT><FONT size=2> {</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>throw</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>LoginException</FONT></FONT><FONT size=2>(</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>LoginExceptionType</FONT></FONT><FONT size=2>.InvalidPassword, </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Invalid password"</FONT></FONT><FONT size=2>);</P><P>}</P><P>}</P><DIV></DIV><DIV>the base.ValidateUserCore() fails as expected</DIV><DIV>&nbsp;</DIV><DIV>It executes the "invalid Password"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new LoginException </DIV><DIV>&nbsp;</DIV><DIV>RESULT: nothing happens and The Unhandled Exception function takes over.</DIV><DIV>&nbsp;</DIV><DIV>1. What should be displayed ( I assume on the login page)</DIV><DIV>2. Why did it not intercept the error?</DIV><DIV>&nbsp;</DIV><DIV>I ask as it is your code and I assumed it should work.</DIV><DIV>&nbsp;</DIV><DIV>This is important to me as I am building a login page to test your devforce .</DIV><DIV>I also need access to roles later.</DIV><DIV>&nbsp;</DIV><DIV>Hope you can help</DIV><DIV>&nbsp;</DIV><DIV>Bruce</FONT></DIV>]]>
   </description>
   <pubDate>Fri, 22 Jan 2010 13:08:18 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1623&amp;PID=6108#6108</guid>
  </item> 
 </channel>
</rss>