2016-09-27 54 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

先生我刚刚编辑我的问题 –

相关问题