你Display跳转的哪个View?
在Display Action加上[POST],然后最后RedirectToAction跳转到相应的Action。public class LoginController : Controller
{
//
// GET: /Login/

public ActionResult Index()
{
return View();
} [HttpPost]
public ActionResult Display(FormCollection values)
{
User obj = new User();
obj.Login = values["login"];
SqlConnection cn = new SqlConnection("Data Source=vdw-nexfi-004;Persist Security Info=True;User ID=gao_s;Password=gao_s");

try
{
SqlCommand cmd = new SqlCommand("select Role from TestDev.dbo.Table_Login where login_windows='" + obj.Login + "'", cn);
cn.Open();
SqlDataReader sdr = cmd.ExecuteReader();
此处略去一万字
}
catch (System.Exception ee)
{
Response.Write(ee.Message.ToString());
}
finally
{
cn.Close();
}

//return View(obj);
return RedirectToAction(Action, Object);
}
}

解决方案 »

  1.   

    Display要跳转到display.aspx, 现在的问题是,我在 public ActionResult Display()前面加个断点,程序其实都不运行这个方法,然后就直接报错了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: /Display
    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1022 
      

  2.   

    想一下页面提交流程,比如你在Global里加啥代码了,执行出错了。