Hi, I have a simple for with at text field where the user enters the address of a RSS feed. I wont act if the field is blank, this is my markup:
<%=Html.ValidationSummary() %>
<table>
<tr>
<td>
Feed Url:
</td>
<td>
<%=Html.TextBox("url", null, new {@style="width:300px"}) %>
</td>
</tr></table>
My controller is also very simple:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult AddFeed(FormCollection collection)
{
string url = collection.Get("url");
string roles = collection.Get("Roles");
if (string.IsNullOrEmpty(url))
{
ModelState.AddModelError("url", "Please provide a propre feed url");
}
if (string.IsNullOrEmpty(roles))
{
ModelState.AddModelError("Roles", "Please select a valid role");
}
if (ModelState.IsValid)
{
Session["url"] = url;
Session["Roles"] = roles;
return RedirectToAction("ValidateFeed");
}
else
{
return View();
}
}
When it fails it reloads the view and makes an exception in the line where it renders my textbox, saying that there has been a null pointer exception. This really botheres me, it should be so simple... but still im struggling
/H4mm3r
Edit Please disregard the Roles element its a drop down i have, but removed it from markup for simplicity