TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
189
24.8k
The resource cannot be found.
May 17 2018 1:03 AM
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.
Controller
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.Mvc;
using
System.Configuration;
using
System.Web.Security;
using
MySql.Data.MySqlClient;
using
NewProject160518.Models;
namespace
NewProject160518.Controllers
{
public
class
HomeController : Controller
{
// GET: Home
string
constr = ConfigurationManager.ConnectionStrings[
"con"
].ConnectionString;
[Authorize]
public
ActionResult Index()
{
return
View();
}
[HttpGet]
public
ActionResult UserLogin()
{
return
View();
}
[HttpPost]
public
ActionResult UserLogin(userlist userlist)
{
MySqlDataReader rd;
MySqlConnection con =
new
MySqlConnection(constr);
con.Open();
string
Query =
"SELECT * FROM userlist where Emailid='"
+userlist.Emailid+
"' and Password ='"
+ userlist.Password+
"'"
;
MySqlCommand cmd =
new
MySqlCommand(Query, con);
rd = cmd.ExecuteReader();
while
(rd.Read())
{
if
(rd.HasRows)
{
ViewData[
"Message"
] =
"Welcome !! "
+userlist.Emailid +
""
;
return
RedirectToAction(
"index"
);
break
;
}
//else
//{
// Response.Write("<script language='javascript'>alert('Invalid EmailI or Password')</script>");
//}
}
return
View();
}
[Authorize]
[HttpPost]
public
ActionResult Logout()
{
FormsAuthentication.SignOut();
//return View();
return
RedirectToAction(
"UserLogin"
);
}
}
}
UserLogin.cshtml
@model NewProject160518.Models.userlist
@{
ViewBag.Title =
"UserLogin"
;
}
<h2>User Login</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div
class
=
"form-horizontal"
>
@Html.ValidationSummary(
true
,
""
,
new
{ @
class
=
"text-danger"
})
<div
class
=
"form-group"
>
@Html.LabelFor(model => model.Emailid, htmlAttributes:
new
{ @
class
=
"control-label col-md-2"
})
<div
class
=
"col-md-10"
>
@Html.EditorFor(model => model.Emailid,
new
{ htmlAttributes =
new
{ @
class
=
"form-control"
} })
@Html.ValidationMessageFor(model => model.Emailid,
""
,
new
{ @
class
=
"text-danger"
})
</div>
</div>
<div
class
=
"form-group"
>
@Html.LabelFor(model => model.Password, htmlAttributes:
new
{ @
class
=
"control-label col-md-2"
})
<div
class
=
"col-md-10"
>
@Html.EditorFor(model => model.Password,
new
{ htmlAttributes =
new
{ @
class
=
"form-control"
} })
@Html.ValidationMessageFor(model => model.Password,
""
,
new
{ @
class
=
"text-danger"
})
</div>
</div>
<div
class
=
"form-group"
>
<div
class
=
"col-md-offset-2 col-md-10"
>
<input type=
"submit"
value=
"Create"
class
=
"btn btn-default"
/>
</div>
</div>
</div>
@ViewData[
"Message"
]
}
<div>
@Html.ActionLink(
"Back to List"
,
"Index"
)
</div>
<script src=
"~/Scripts/jquery-1.10.2.min.js"
></script>
<script src=
"~/Scripts/jquery.validate.min.js"
></script>
<script src=
"~/Scripts/jquery.validate.unobtrusive.min.js"
></script>
Index.cshtml
@{
ViewBag.Title =
"Index"
;
}
<h2>Index</h2>
Welcome @HttpContext.Current.User.Identity.Name
@
if
(Request.IsAuthenticated)
{
using (Html.BeginForm(
"Logout"
,
"Home"
, FormMethod.Post,
new
{ id=
"logoutForm"
}))
{
<a href=
"javascript:document.getElementById('logoutForm').submit()"
>Logout</a>
}
}
Reply
Answers (
2
)
Directly print .rdlc report (without preview) in Asp.Net Mvc
Asp.net Web method how to access asp.net controls