namespace proyPrueba.Models
{
public class Cuenta
{
public string Nameu { get; set; }
public string passwordus { get; set; }
public string Cargo { get; set; }
}
}
namespace proyPrueba.Controllers
{
public class CuentaController : Controller
{
SqlConnection con = new SqlConnection();
SqlCommand com = new SqlCommand();
SqlDataReader dr;
// GET: Cuenta
[HttpGet]
public ActionResult Login()
{
return View();
}
void connectionString()
{
con.ConnectionString = "data source=DESKTOP-6C8HTE4; database=Naturist3_0; integrated security=true;";
}
[HttpPost]
public ActionResult Verify(Cuenta acc)
{
connectionString();
con.Open();
com.Connection = con;
com.CommandText = "select username, password, rol from usuario where username='"+acc.Nameu+"', password='"+acc.passwordus+"' and rol='"+acc.Cargo+"'";
dr = com.ExecuteReader();
if(dr.Read())
{
con.Close();
if(rol='Administrador')
{
}
return Redirect ("../sitioWeb/Inicio.aspx");
}
else
{
con.Close();
return View("error");
}
}
}
}
Respuesta
¿Demasiados anuncios?
Javier Segarra Martinez
Puntos
20
0 votos
¿Lo que quieres es redirigir a páginas distintas?¿O que la pantalla de login esté en distintas URLs?