2016-09-27 1 views
0

ich erstelle eine web-app und ich möchte seite auf taste klicken klicken und ich habe alle textbox und taste als eingabefeld ich kann nicht viel darüber im internet sehen , wie kann ich umleiten zu einer anderen Seite auf Knopf klicken (wenn Identifikation und Kennwort wird validiert)mvc 5 validieren und umleiten auf eine andere seite auf taste klicken

für zB ich tat alle sql in Verbindung stehende Fragen in modal und ich übertrage wahr oder falsch von modal (if true(redirect to login page))(if false(redirect to signup page)), was ich auf meinem tun muss Controller

[HttpPost] 
    public ActionResult testlogin(string username, string password) 
    { 
     // called my modal here and creates its object(modal m=new modal();) 
     //what to do now 
    } 

in meinem modal ich habe sQL-Abfrage wie

`sql command cmd=new sqlcommand("select * from empdet where empid='"+user+"' and pass='"+password+"'",con); 
con.open(); 
SqlDataAdapter da=new SqlDataAdapter(cmd); 
dataset ds=new dataset(); 
da.fill(ds); 
if(ds.tables[0].rows.count>0) 
{ 
bool true; 
} 
else 
{ 
bool false; 
} 
con.close(); 
bool = Convert.ToBoolean(cmd.ExecuteReader()); 
return user;` 

wenn bool true zurückgibt, sollte die Seite umleiten werden Seite zu begrüßen sonst Seite

+0

Mögliches Duplikat von [How von einem anderen Controller zum Index umleiten?] (http://stackoverflow.com/questions/7892094/how-to-redirect-to-index-from-another-controller) –

+0

@WillRay Herr redigierte meine Frage –

Antwort

1

Versuchen Sie dieses verwenden: -

[HttpPost] 
public ActionResult testlogin(string username, string password) 
{ 
    // called my modal here and creates its object(modal m=new modal();) 
    bool loginResult= call your model method 
    if(loginResult) 
    { 
     return RedirectToAction("Welcome","Home"); 
    } 
    else 
    { 
     return RedirectToAction("Login","Home"); 
    } 
} 
0

Verwendung anmelden umleiten

[HttpPost] 
public ActionResult testlogin(string username, string password) 
{ 
    return Response.Redirect("../HomeIndex?Option=Please_log_in_as_user"); 
} 

oder

[HttpPost] 
public ActionResult testlogin(string username, string password) 
{ 
    return RedirectToAction("AddressDelivery", "BuyOnline", new { Option = "SetAsDeliveryAddress" }); 

// first one is action, second is controller name, then if needed parameters 
} 
+0

Herr ich gerade redigiert meine Frage –

Verwandte Themen