Question

I have the following code:

<% using (Html.BeginForm("AddComment", "Comments", FormMethod.Post)) { %>
<div id="New_Comment">
<textarea name="newComment" id="newComment">Add comments</textarea>
<input type="submit" value="Add" />
<div><span class="text_grey">Attach:</span><a href="#" class="link_text_grey">File</a> <a href="#" class="link_text_grey">Link</a></div>
</div>
<%} %>

This is in a partial rendered by the MyPage controller. For some reason the action on the form comes out blank, if I reference a method on the MyPage controller it works fine what I want to do is point to a different controller with my form.

Was it helpful?

Solution

To solve this issue I simple added in an area route value like so:

new { area = "" }

With the empty string directing the route to the default area.

OTHER TIPS

1) Is your "Comments" action marked as being a POST action?

2) Also

Try just doing:

<% Html.BeginForm("AddComment", "Comments"); %>

// Html and script

<% Html.EndForm(); %>

I know that there shouldn't be difference between what you have and what I suggest, but it's worth a try.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top