Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i write this code in HttpGet Index Control :
C#
[HttpGet]
        public ActionResult Index(int id)
        {
		var model=_db.nezam.tolist();
		return view(model);
		}


and in view i have a form :
HTML
@using(Html.BeginForm()){
<input type="text" name="cap" />
<input type="submit"  value="OK" />
}


in httpost i write :
HTML
[HttpPost]
    public ActionResult Index(string cap)
      {
          string st=HttpContext.Session["captcha"].ToString();
          if (cap == st)
          {
              return Content("true");
          }
          return View(?);
      }


when i run my project and click on ok button give me this error :
HTML
System.NullReferenceException: Object reference not set to an instance of an object.


it is true because i dont sent any model to view , but i dont know how get model from html.beginform and next send it to view again ,=== return View(?)?????
Posted
Comments
NorouziFar 23-Jun-14 23:21pm    
how?

1 solution

You REALLY need to pick up book on MAC. There's plenty more concepts you're missing on top of just getting a form to post.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900