1

I'm writing an MVC website in C# with razor syntax.

I have some code here:

@using (Html.BeginForm("DoSignUp", "SignUpController", FormMethod.Post)) 
{
    <input type="text" width="3000" value="" name="Name" />
    <input type="submit" value="Register" /
}

So this form should post to the SignUpController on the DoSignUp method. Instead of doing that it just posts back to the page I'm currently on which is called SignUp. I suspected there might be something wrong with my routing but when I look at the html that is being generated through the browser developer tools i see this:

<form action="" method="post">        
    <input type="text" width="3000" value="" name="selectedURL">
    <input type="submit" value="Register">
</form>

Edit: Well I wrote this out and then looked at my code again. The problem which I keep bloody doing is that SignUpController should just be SignUp.

1
  • 2
    Use SignUp , not SignUpController. @using (Html.BeginForm("DoSignUp", "SignUp", FormMethod.Post)) Commented Dec 13, 2017 at 14:15

1 Answer 1

2

Remove the 'Controller' from your controller name (SignUp, not SignUpController). It's assumed to be a controller by convention

@using (Html.BeginForm("DoSignUp", "SignUp", FormMethod.Post)) 
{
    <input type="text" width="3000" value="" name="Name" />
    <input type="submit" value="Register" /
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.