2016-09-27 55 views
0

我正在創建一個web應用程序,我想重定向頁面上的按鈕單擊,我用所有的文本框和按鈕作爲輸入字段,我無法在互聯網上看到很多,我怎麼能重定向到另一個頁面上的按鈕點擊(如果身份證和密碼驗證)mvc 5驗證並重定向到按鈕上的另一個頁面點擊

例如我做了所有與模態相關的sql查詢,我從模態傳遞true或false (if true(redirect to login page))(if false(redirect to signup page))我需要做什麼我的控制器

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

我有一個像

0 SQL查詢

如果布爾返回true,頁面應該重定向到歡迎頁面,否則重定向到登錄頁面

+0

可能重複[How重定向到另一個控制器的索引?](http://stackoverflow.com/questions/7892094/how-to-redirect-to-index-from-another-controller) –

+0

@WillRay先生編輯我的問題 –

回答

1

試試這個: -

[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

使用可以使用

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

[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

先生我剛剛編輯我的問題 –

相關問題