Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Discussions

erik erik_ Whooops!
  • How can I switch live id account for logon to site?

    Hi Duncanma,

    Can you move the live id account settings from the eriklieben account to this account?

    Thanks!

  • How can I switch live id account for logon to site?

    Hi,

    I currently have my account set to a live id account that's not my primary live id anymore.

    Does anyone know how I could switch to anoter live id?

    Thanks,

    Erik

  • Where to look for online account setup?

    Try the ASP.NET Membership provider : http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx or http://odetocode.com/Articles/427.aspx.

     

     

  • (MsBuild) StyleCop task

    It's great that it is availible now, but I find some of the rules a bit weird. They differ from the default behavior of the visual studio templates. For example the:

    SA1200: All using directives must be placed inside of the namespace.

    Is there any documentation availible on the why, just like there is with fxcop?

  • Software ​Documentati​on

    That sounds like user documentation Big Smile

    Documentation of knowledge is very very usefull if you need to continue a project from someone else or start a new one, finish and modify it a year later. Good requirements is a must have. Questionable is if you are the one to create them or if the shop is large enough to have a person around to perform this tasks. I feel more and more that I need that knowledge on paper, because it now comes back as bugs and needs to get solved asap while I am working on something else. The only real problem is that documentation takes time upfront, while the problems from not having documentation is time afterwards and not visible.

    Comments in code aren't always good, good comments in code are.
    I've seen this extreme commenting pratice, which is not helpfull in any way. The code is full of stuff like this:

    // Close the stream
    writer.Close();


    Next to the extra space it takes, and all the green lines in the code it is also not very good if you refactor a lot. If I use VS refactor/rename for example, it will not modify any comments. You will end up with comments saying this does X while it actually does Y.

  • How to catch exceptions raised by Custom Membership provider?

    Maby it is more clear if you just see the code. Here is my solution file: sample_membership_provider.zip (vs 2008 solution)

    Let me know if there still is anything unclear after looking at the project.


    Edit: updated project, forgot to add website. You probaly need to readd the website with the correct path, because it points to my f:\projects\test folder instead of the current folder.

  • How to catch exceptions raised by Custom Membership provider?

    You should never need to call the custom membership provider directly. To let the provider pattern make sense you should only talk to your custom membership provider thrue the membership object.

    By directly calling the custom membership provider object you are not able to switch membership providers in the membership web.config section.

    Just to make sure you understand my last post, this is what that gives in aspx modified to your last code snipped. This will do the same as the code you have only than catch the exception and display it into the failuretext.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%
    @ Register Assembly="member" Namespace="member" TagPrefix="asp" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head runat="server">
    <title>Untitled Page</title>
    </
    head>
    <
    body>
    <form id="form1" runat="server">
       <div>
          <asp:Login2 ID="Login2" runat="server"></asp:Login2>
       </div>
    </form>
    </
    body>
    </
    html>


    public class Login2 : System.Web.UI.WebControls.Login {

    protected
    override void OnAuthenticate(System.Web.UI.WebControls.AuthenticateEventArgs e) { 
       try {
          base.OnAuthenticate(e);
       }
    catch (Exception ex) {
          this.FailureText = ex.Message;
          this.OnLoginError(EventArgs.Empty);
       }
    }
    }

  • How to catch exceptions raised by Custom Membership provider?

    You can't catch the Exception the way you want it, with the default login control as far as I know.

    What you can do is create a global.asax file and catch all exceptions (or check if the exception is a membershipprovider exception) and do something like:

    <%@ Application Language="C#" %>

    <script runat="server">

    void Application_Error(object sender, EventArgs e) {

       // Code that runs when an unhandled error occurs
       
    Response.Redirect(http://www.google.com);
    }

    </script>

  • How to catch exceptions raised by Custom Membership provider?

    public class Login2 : System.Web.UI.WebControls.Login {

       protected override void OnAuthenticate (System.Web.UI.WebControls.AuthenticateEventArgs e) {
          try {
             base.OnAuthenticate(e); 
          }
    catch (Exception ex) { 
             HttpContext.Current.Response.Write("ex: " + ex.Message);
             // or HttpContext.Response.Redirect("http://www.google.com");
          }
       }
    }

    this is the other option...

    I hope any of these is what you are looking for, because I think I don't fully understand your needs.

  • How to catch exceptions raised by Custom Membership provider?

    protected void Page_Load(object sender, EventArgs e) {
       Page.Error +=
    new EventHandler(Page_Error);
    }

    void Page_Error(object sender, EventArgs e) {
       Response.Redirect(
    http://www.google.com);
    }

    is the same as what happends in the global.asax only than on page level. Still it catches all the exceptions happening on the page. Using the global.asax is a perfect way for this if you ask me. You are able to display a generic help message and mail home or log the exception for every exception in the webapplication. Than you at least known that it happends for each page in your webapplication, instead of only the ones that you didn't forget to add the above.

    An other option is to create your own implementation or inherit the asp.net login control and add the exception handling.


    Don't forget, Exceptions are for exceptional problems. Not to control the flow..