omegalove
asked on
Added extra fields to the profile membership.
When I tried to login it gives me an error with the new user I created. If I try to login with older user account then I can log in properly.
Server Error in '/' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
The 'src' property had a malformed URL: Cannot use a leading .. to exit above the top directory..
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The 'src' property had a malformed URL: Cannot use a leading .. to exit above the top directory..
Source Error:
Line 40: <div class="header">
Line 41: <div class="header-logo">
Line 42: <a href="<%=Page.ResolveUrl(" ~/Default. aspx")%>" class="logo"> </a>
Line 43: </div>
Line 44: <div class="header-login">
Source File: c:\inetpub\wwwroot\OmegaLo ve.Web\Ome gaLove.Web \MasterPag es\Root.Ma ster Line: 42
Stack Trace:
Server Error in '/' Application.
--------------------------
The 'src' property had a malformed URL: Cannot use a leading .. to exit above the top directory..
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The 'src' property had a malformed URL: Cannot use a leading .. to exit above the top directory..
Source Error:
Line 40: <div class="header">
Line 41: <div class="header-logo">
Line 42: <a href="<%=Page.ResolveUrl("
Line 43: </div>
Line 44: <div class="header-login">
Source File: c:\inetpub\wwwroot\OmegaLo
Stack Trace:
ASKER
why when i login with an old user it works.
Please explain us the scenario.
for example,
1. you are going to myproject/registration/new member.asp x to create a new user
2. in that page, you are redirecting the user to myproject/Default.aspx
for registered user,
3. you are in myproject/login/login.aspx
4. on successful login, you are redirecting the user to myproject/Default.aspx
Please revert
for example,
1. you are going to myproject/registration/new
2. in that page, you are redirecting the user to myproject/Default.aspx
for registered user,
3. you are in myproject/login/login.aspx
4. on successful login, you are redirecting the user to myproject/Default.aspx
Please revert
ASKER
I created the user through a register page with a profile set in the web config file.
public partial class ctrlLogin : OmegaLoveBasePageUserContr ol
{
protected MembershipUser loginUser;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Search recursively for a Login control, called LoginStatus
// starting from within the Page object.
Login curLogin = FindControl<Login>(this, "LoginStatus");
// You still should check whether you got something back!
if (curLogin != null)
Page.SetFocus(curLogin.Fin dControl(" UserName") );
}
}
// Search recursively a control sub-tree for a specific control.
// It searches every control in the sub-tree, so it potentially
// could be optimized to search only, say, INamingContainers.
public Control FindControlRecursive(Contr ol root, string id)
{
if (root.ID == id) return root;
foreach (Control c in root.Controls)
{
var ctlFound = FindControlRecursive(c, id);
if (((ctlFound != null))) return ctlFound;
}
return null;
}
public T FindControl<T>(string id) where T : Control
{
return FindControl<T>(Page, id);
}
public static T FindControl<T>(Control startingControl, string id) where T : Control
{
T found = null;
foreach (Control activeControl in startingControl.Controls)
{
found = activeControl as T;
if (found == null)
{
found = FindControl<T>(activeContr ol, id);
}
else if (string.Compare(id, found.ID, true) != 0)
{
found = null;
}
if (found != null)
{
break;
}
}
return found;
}
protected void btnLogout_Click(object sender, EventArgs e)
{
this.Context.Session.Clear ();
this.Context.Session.Aband on();
FormsAuthentication.SignOu t();
FormsAuthentication.Redire ctToLoginP age();
Response.Redirect(FormsAut henticatio n.LoginUrl );
}
protected void LoginStatus_Authenticate(o bject sender, AuthenticateEventArgs e)
{
var lgnMain = ((Login)LoginView1.FindCon trol("Logi nStatus")) ;
string username = lgnMain.UserName;
if (Membership.ValidateUser(l gnMain.Use rName, lgnMain.Password))
{
FormsAuthentication.Redire ctFromLogi nPage(lgnM ain.UserNa me, false);
Response.Redirect("~/Secur e/UserProf ile.aspx", false);
}
else
{
lgnMain.FailureText = "Your login attempt was not successful. Please try again.";
Image ImageError = new Image();
ImageError = ((Image)LoginView1.FindCon trol("Logi nStatus"). FindContro l("ImageEr ror"));
ImageError.Visible = true;
}
MembershipUser usrInfo = Membership.GetUser(lgnMain .UserName) ;
if (usrInfo != null)
{
// Is this user locked out?
if (usrInfo.IsLockedOut)
{
lgnMain.FailureText = "Your account has been locked out because of too many invalid login attempts. Please contact the admin" +
"istrator to have your account unlocked.";
}
else if (!usrInfo.IsApproved)
{
lgnMain.FailureText = "Your account has not yet been approved. You cannot login until an administrator has approved your acc" +
"ount.";
}
}
}
protected void ImgRegister_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("~/Secur e/Register .aspx");
}
public partial class ctrlLogin : OmegaLoveBasePageUserContr
{
protected MembershipUser loginUser;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Search recursively for a Login control, called LoginStatus
// starting from within the Page object.
Login curLogin = FindControl<Login>(this, "LoginStatus");
// You still should check whether you got something back!
if (curLogin != null)
Page.SetFocus(curLogin.Fin
}
}
// Search recursively a control sub-tree for a specific control.
// It searches every control in the sub-tree, so it potentially
// could be optimized to search only, say, INamingContainers.
public Control FindControlRecursive(Contr
{
if (root.ID == id) return root;
foreach (Control c in root.Controls)
{
var ctlFound = FindControlRecursive(c, id);
if (((ctlFound != null))) return ctlFound;
}
return null;
}
public T FindControl<T>(string id) where T : Control
{
return FindControl<T>(Page, id);
}
public static T FindControl<T>(Control startingControl, string id) where T : Control
{
T found = null;
foreach (Control activeControl in startingControl.Controls)
{
found = activeControl as T;
if (found == null)
{
found = FindControl<T>(activeContr
}
else if (string.Compare(id, found.ID, true) != 0)
{
found = null;
}
if (found != null)
{
break;
}
}
return found;
}
protected void btnLogout_Click(object sender, EventArgs e)
{
this.Context.Session.Clear
this.Context.Session.Aband
FormsAuthentication.SignOu
FormsAuthentication.Redire
Response.Redirect(FormsAut
}
protected void LoginStatus_Authenticate(o
{
var lgnMain = ((Login)LoginView1.FindCon
string username = lgnMain.UserName;
if (Membership.ValidateUser(l
{
FormsAuthentication.Redire
Response.Redirect("~/Secur
}
else
{
lgnMain.FailureText = "Your login attempt was not successful. Please try again.";
Image ImageError = new Image();
ImageError = ((Image)LoginView1.FindCon
ImageError.Visible = true;
}
MembershipUser usrInfo = Membership.GetUser(lgnMain
if (usrInfo != null)
{
// Is this user locked out?
if (usrInfo.IsLockedOut)
{
lgnMain.FailureText = "Your account has been locked out because of too many invalid login attempts. Please contact the admin" +
"istrator to have your account unlocked.";
}
else if (!usrInfo.IsApproved)
{
lgnMain.FailureText = "Your account has not yet been approved. You cannot login until an administrator has approved your acc" +
"ount.";
}
}
}
protected void ImgRegister_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("~/Secur
}
Can you tell me in which page the attached code is in?
i mean, <project>/Secure/SomePage. aspx
i mean, <project>/Secure/SomePage.
Source Error:
Line 40: <div class="header">
Line 41: <div class="header-logo">
Line 42: <a href="<%=Page.ResolveUrl("~/Default.aspx")%>" class="logo"> </a>
Line 43: </div>
Line 44: <div class="header-login">
ASKER
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="LoginStatus" RememberMeSet="false" runat="server" Height="30px" Width="100%"
DestinationPageUrl="~/Secu re/UserPro file.aspx" OnAuthenticate="LoginStatu s_Authenti cate">
<LayoutTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%"
style="height: 90px">
<tr>
<td nowrap="nowrap" width="25%">
<img id="UHorLogin1_Image2" src="../Images/Icons/login 1.gif" style="height: 25px;
width: 25px; border-width: 0px;" align="middle" /><asp:Label runat="server" ID="lblUserName"
AssociatedControlID="UserN ame" Text="Username:" />
<asp:TextBox ID="UserName" runat="server" BorderColor="DarkGray" BorderStyle="Inset"
BorderWidth="2px" Width="105px" />
</td>
<td width="9px" style="text-align: left;" valign="middle">
<asp:RequiredFieldValidato r ID="valRequireUserName" runat="server" SetFocusOnError="True"
ControlToValidate="UserNam e" Text="*" ValidationGroup="Login" Font-Bold="True" />
</td>
<td nowrap="nowrap" width="25%">
<img id="UHorLogin1_Image1" src="../Images/Icons/passw ordsmall.g if" style="border-width: 0px;"
align="middle" />
<asp:Label ID="lblPassword" runat="server" AssociatedControlID="Passw ord" Text="Password:" />
<asp:TextBox ID="Password" runat="server" TextMode="Password" BorderColor="DarkGray"
BorderStyle="Inset" BorderWidth="2px" Width="105px" />
</td>
<td width="9px" style="text-align: left;" valign="middle">
<asp:RequiredFieldValidato r ID="valRequirePassword" runat="server" ControlToValidate="Passwor d"
SetFocusOnError="True" Text="*" ValidationGroup="Login" Font-Bold="True" />
</td>
<td width="25%">
<asp:Button CssClass="button-login" ValidationGroup="Login" CommandName="Login" ID="btnLogin"
runat="server" />
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<asp:ImageButton ID="ImgRegister" runat="server" ImageUrl="../Images/Button s/newslett er_button. gif"
ImageAlign="Top" OnClick="ImgRegister_Click " />
<asp:HyperLink ID="lnkPasswordRecovery" runat="server" NavigateUrl="~/Secure/Pass wordRecove ry.aspx">F orgot
password?</asp:HyperLink>& nbsp;
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<input type="text" name="theTime" size="30" readonly="readonly" style="border: 0px;
background-image: none; margin-left: 4px; font-weight: bold;">
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<asp:Image ID="ImageError" runat="server" Width="22px" Height="16px" ImageAlign="Top"
src="../Images/Icons/alert .gif" Visible="false" />
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></ asp:Litera l>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</AnonymousTemplate>
<LoggedInTemplate>
<div id="welcomebox">
<asp:LoginName ID="LoginName1" runat="server" FormatString=" Welcome {0} " />
<asp:Button CssClass="button-logout" ID="btnLogout" runat="server" OnClick="btnLogout_Click" /><br />
<input type="text" name="theTime" size="30" readonly="readonly" style="border: 0px;
background-image: none; margin-left: 4px; font-weight: bold;">
</div>
</LoggedInTemplate>
</asp:LoginView>
<AnonymousTemplate>
<asp:Login ID="LoginStatus" RememberMeSet="false" runat="server" Height="30px" Width="100%"
DestinationPageUrl="~/Secu
<LayoutTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%"
style="height: 90px">
<tr>
<td nowrap="nowrap" width="25%">
<img id="UHorLogin1_Image2" src="../Images/Icons/login
width: 25px; border-width: 0px;" align="middle" /><asp:Label runat="server" ID="lblUserName"
AssociatedControlID="UserN
<asp:TextBox ID="UserName" runat="server" BorderColor="DarkGray" BorderStyle="Inset"
BorderWidth="2px" Width="105px" />
</td>
<td width="9px" style="text-align: left;" valign="middle">
<asp:RequiredFieldValidato
ControlToValidate="UserNam
</td>
<td nowrap="nowrap" width="25%">
<img id="UHorLogin1_Image1" src="../Images/Icons/passw
align="middle" />
<asp:Label ID="lblPassword" runat="server" AssociatedControlID="Passw
<asp:TextBox ID="Password" runat="server" TextMode="Password" BorderColor="DarkGray"
BorderStyle="Inset" BorderWidth="2px" Width="105px" />
</td>
<td width="9px" style="text-align: left;" valign="middle">
<asp:RequiredFieldValidato
SetFocusOnError="True" Text="*" ValidationGroup="Login" Font-Bold="True" />
</td>
<td width="25%">
<asp:Button CssClass="button-login" ValidationGroup="Login" CommandName="Login" ID="btnLogin"
runat="server" />
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<asp:ImageButton ID="ImgRegister" runat="server" ImageUrl="../Images/Button
ImageAlign="Top" OnClick="ImgRegister_Click
<asp:HyperLink ID="lnkPasswordRecovery" runat="server" NavigateUrl="~/Secure/Pass
password?</asp:HyperLink>&
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<input type="text" name="theTime" size="30" readonly="readonly" style="border: 0px;
background-image: none; margin-left: 4px; font-weight: bold;">
</td>
</tr>
<tr>
<td width="100%" colspan="5" style="text-align: right;">
<asp:Image ID="ImageError" runat="server" Width="22px" Height="16px" ImageAlign="Top"
src="../Images/Icons/alert
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</AnonymousTemplate>
<LoggedInTemplate>
<div id="welcomebox">
<asp:LoginName ID="LoginName1" runat="server" FormatString=" Welcome {0} " />
<asp:Button CssClass="button-logout" ID="btnLogout" runat="server" OnClick="btnLogout_Click" /><br />
<input type="text" name="theTime" size="30" readonly="readonly" style="border: 0px;
background-image: none; margin-left: 4px; font-weight: bold;">
</div>
</LoggedInTemplate>
</asp:LoginView>
ASKER
I changed this in the web.config
<profile defaultProvider="OmegaLove ProfilePro vider" inherits="OmegaLove.BLL.Cu stomProfil e">
<providers>
<add name="OmegaLoveProfileProv ider" type="System.Web.Profile.S qlProfileP rovider" applicationName="Omegalove .Web" connectionStringName="Loca lSqlServer " />
</providers>
</profile>
<profile defaultProvider="OmegaLove ProfilePro vider" inherits="OmegaLove.BLL.Cu stomProfil e">
<providers>
<add name="OmegaLoveProfileProv ider" type="System.Web.Profile.S qlProfileP rovider" applicationName="/" connectionStringName="Loca lSqlServer " />
</providers>
</profile>
<profile defaultProvider="OmegaLove
<providers>
<add name="OmegaLoveProfileProv
</providers>
</profile>
<profile defaultProvider="OmegaLove
<providers>
<add name="OmegaLoveProfileProv
</providers>
</profile>
ASKER
<membership defaultProvider="OL_Member
<providers>
<add name="OL_MembershipProvide
</providers>
</membership>
<!--<profile defaultProvider="OL_Profil
<providers>
<clear />
<add name="OL_ProfileProvider" type="System.Web.Profile.S
</providers>
<properties>
<add name="Address" type="OmegaLove.BLL.Addres
<add name="Personal" type="OmegaLove.BLL.Person
<add name="Preferences" type="OmegaLove.BLL.Prefer
</properties>
</profile>-->
<profile defaultProvider="OmegaLove
<providers>
<add name="OmegaLoveProfileProv
</providers>
</profile>
this needs to be set in one of the tables.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes but it worked with until I adding extra fields in the Personal.cs
So it seems like it is pointing to the wrong applicationname
When I register a new user in my registration page.
Goto omegalove. and click on register than try to login.
So it seems like it is pointing to the wrong applicationname
When I register a new user in my registration page.
Goto omegalove. and click on register than try to login.
ASKER
k
You need to give us what exactly you are trying to do?
I think you are keeping your create user page in someother folder other than the folder in which Default.aspx is?
If so, give the correct path?
Regards.