I want to restrict the users who not log in.for this I wrote the following,
but it doesn't redirects to the log in page,just gives error like,
The resource cannot be found.
Description:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Account/LogOn,
how to resolve this,If any one know the answer plz send me.
Description:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Description:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
chandana G
Member
7 Points
69 Posts
how to redirect unauthorized person to log in page
May 11, 2012 05:58 AM|LINK
Hi,
I developed some controllers for my products,
I want to restrict the users who not log in.for this I wrote the following,
but it doesn't redirects to the log in page,just gives error like,
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Account/LogOn,
how to resolve this,If any one know the answer plz send me.
mishra.bhupe...
Participant
1596 Points
378 Posts
Re: how to redirect unauthorized person to log in page
May 11, 2012 06:08 AM|LINK
What you have wrote?
Check your code where you have given login page URL.It seems to be incorrect, it is causing the error. Put there correct url .
chandana G
Member
7 Points
69 Posts
Re: how to redirect unauthorized person to log in page
May 11, 2012 06:32 AM|LINK
where should I place that,
below is my code in site master,
<div id="logindisplay">
<%
if (Html.IsAuthenticated())
{
Response.Write(string.Format("Welcome {0}", Html.GetUserName()));
Response.Write(" | ");
// Response.Write(Html.ActionLink("Edit My Profile", "Logout", "Account"));
Response.Write(Html.ActionLink("Logout", "Logout", "Account"));
}
else
{
Response.Write(Html.ActionLink("Login", "Login", "Account"));
}
%>
|
<%: Html.ActionLink("en", "ChangeCulture", "Account", new { lang = "en", returnUrl = this.Request.RawUrl }, null) %>
|
<%: Html.ActionLink("da", "ChangeCulture", "Account", new { lang = "da", returnUrl = this.Request.RawUrl }, null) %>
</div>
<div id="menucontainer">
<ul id="menu">
<li>
<%: Html.ActionLink("Home", "Index", "Home")%></li>
<%
if (Html.IsAuthenticated())
{
%>
<li><%: Html.ActionLink("Products", "Index", "Product")%></li>
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: how to redirect unauthorized person to log in page
May 11, 2012 06:49 AM|LINK
AuthorizeAttribute on the action. (As much as possible, the view should not have business logic)
chandana G
Member
7 Points
69 Posts
Re: how to redirect unauthorized person to log in page
May 11, 2012 07:13 AM|LINK
yes I done that only ,
but but I got the above error,
[Authorize]
public ViewResult Index()
{
var who = SessionHelper.GetUserName();
return View(db.ProductGroups.Where(p=>p.CreatedBy==who).ToList());
}
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Account/LogOn
asp.netmvc3
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: how to redirect unauthorized person to log in page
May 11, 2012 07:21 AM|LINK
and do you have
/Account/LogOn
( controller / action?)
chandana G
Member
7 Points
69 Posts
Re: how to redirect unauthorized person to log in page
May 11, 2012 07:28 AM|LINK
no but I have Account Controller with some action methods like,
Login, Logout,ResetPassword,Register,........
asp.netmvc3
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: how to redirect unauthorized person to log in page
May 11, 2012 07:35 AM|LINK
do you have webmatrix dll referenced? ( either reference, either bin_deployable_assemblies folder)
asp.netmvc3
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: how to redirect unauthorized person to log in page
May 11, 2012 07:36 AM|LINK
see
http://stackoverflow.com/questions/4087300/asp-mvc-problem-with-configuration-of-forms-authentication-section
asp.netmvc3
chandana G
Member
7 Points
69 Posts
Re: how to redirect unauthorized person to log in page
May 11, 2012 08:44 AM|LINK
Thank you somuch ,
I got the solution.
but after log in when I select new link(product),
again it redirects to the login page only