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
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
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
Try the ASP.NET Membership provider : http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx or http://odetocode.com/Articles/427.aspx.
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?
That sounds like user documentation ![]()
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();
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.
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.
<%@
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>
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:
<
script runat="server"> void Application_Error(object sender, EventArgs e) {
public
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.
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..
How are you calling the membership validateuser? thru the asp:login control or just from the code behind?
try
{
Membership.ValidateUser("erik",
"test");
} catch (Exception ex) {
}
should catch the exception thrown from validateuser