Hi I'm new to ASP MVC, I have a simple question for my login page routing, i got stuck on authentication routes. Could you help me please.
When I attempt to login, it shows:
Server Error in '/' Application.
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: /Verify
What I have tried:
AccountController:
[HttpGet]
public ActionResult Login()
{
return View();
}
void connectionString()
{
con.ConnectionString = @"Data Source=.\SQLEXPRESS; Database=WPF; Integrated Security=SSPI";
}
[HttpPost]
public ActionResult Verify(Account acc)
{
connectionString();
con.Open();
com.Connection = con;
com.CommandText = "SELECT * FROM tbl_login where username = '" + acc.Name + "' AND password = '" + acc.Password + "'";
dr = com.ExecuteReader();
if (dr.Read())
{
con.Close();
return View("Create"); }
else
{
con.Close();
return View("Error"); }
RouteConfig.cs
routes.MapRoute(
name: "Account",
url: "Account/{action}/{id}",
defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);