将输入文本从表单视图发布到控制器MVC

时间:2013-10-16 23:21:36

标签: c# asp.net-mvc forms

所以我在共享布局页面上有一个表单,我想简单地发一个文本字符串。我目前在控制器中的操作开始时有一个断点,用于测试表单是否正常工作但看起来它永远不会到达那里因为它永远不会到达断点。这是我的代码,任何人都知道我做错了什么?

查看:

<form action="/RespondentSearch/Search" method="post" class="sidebarSearch">
                    <input type="text" name="search" placeholder="respondent search..." id="ac" class="ui-autocomplete-input" autocomplete="off" /><span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>
                    <input type="submit" value="" href="#moadalSearch" rel="lightbox" />
                </form>

控制器:

public class RespondentSearchController : Controller
    {
        [HttpPost]
        public ActionResult Search(string search)
        {
            string stuff = search;

            return View();
        }
    }

我的Visual Studio调试控制台虽然读起来有异常吗?

Following route: {controller}/{action}/{id} for request: http://localhost:56554/RespondentSearch/Search
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
Following route: {controller}/{action}/{id} for request: http://localhost:56554/Home/Login
Following route: {controller}/{action}/{id} for request: http://localhost:56554/

我的开发人员工具浏览器调试:

Request URL:http://localhost:56554/RespondentSearch/Search
Request Method:POST
Status Code:302 Found
search:asdf <--- This is what I was typing in

看来它已经到了,但我还没有打破我的断点?我还添加了一个临时视图,只是输出一些东西,但仍然没有。这就像它完全避免了我的控制器动作。

0 个答案:

没有答案
相关问题