views:

251

answers:

1

My view:

/User/EditUserName/2/me

<viewdata model="EditUserNameViewData" />
<form action="~/User/EditUserName" method="post" class="span-15 last">
!{Html.TextBox("newUserName")}
<Submit id='"chooseNewName"' value='"Choose new name"' />
</form>

Controller actions:

[AcceptVerbs(HttpVerbs.Get)] public ActionResult EditUserName(int id) { EditUserNameViewData vd = new EditUserNameViewData(); vd.ExistingName = _userRepository.Get(id).UserName; return View("EditUserName", vd); }

[AcceptVerbs(HttpVerbs.Post)] public ActionResult EditUserName(string newUserName) { try { // fails } catch(RulesException errors) { errors.AddModelStateErrors(ModelState, string.Empty); return View(); } }

the return View() does not seem to work as it redirects to

/User/EditUserName

and gives me a 404 error. WTF? I'm using xVal for validation and everything on that end works just can't get it to redisplay the prior page with the information the user put in displayed in the box. Anyone know what I'm doing wrong? This is driving me insane!

Edit

I'm not sure if this is a bug in Spark or what the heck is going on. As soon as I add a EditUserName.aspx page I'm not getting a 404 error anymore and it's working properly, by reshowing the page no problem??? How the heck are other people not running into this issue? I've read everything I could find and I don't see anything wrong with what I'm doing. Why would it work with the regular view engine? I so don't want to switch back to using the other one just for user input but I feel like I have no other choice here.

View:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<form action="/User/EditUserName/<%= ((EditUserNameViewData)ViewData.Model).User.Id %>/<%= ((EditUserNameViewData)ViewData.Model).User.UserName %>" method="post" class="span-15 last">
<input type="text" id="newUserName" name="newUserName" />
<input type="submit" id="chooseNewName" value="Choose new Name" />
</form>
A: 

I was calling Html.RenderAction within my master page. I was "post"ing my form, but my action method had a [AcceptVerbs(HttpVerbs.Get)] attribute on it - this was forcing a 404 error not found and it was obviously my fault. Super glad I figured it out, but geez what a pain.

rball