0

I have:

public ActionResult Create(Guid appId)
{
    var vm = new CreateViewModel(appId);

    return View(vm);
}

[HttpPost]
public ActionResult Create(CreateViewModel vm)
{
    // this does some stuff
}

Now, in the View I use this for creating the Form:

@using(Html.BeginForm())
{

}

Standard.

How ever, it produces the wrong HTML:

<form action="/SomeController/Create?appId=414FDS-45F2SF-TEF234">

This is not what I want posted back, I don't want appId what so ever. Just the Create

How do you get around this?

1 Answer 1

5

You can use another overload of Html.BeginForm to explicitly specify the action you want:

@using(Html.BeginForm("Create", "SomeController"))
{

}

This will not append anything to the URL by default.

Sign up to request clarification or add additional context in comments.

5 Comments

Okay, so this won't add that get request on then
@No1_Melman, no, it will generate just /SomeController/Create.
Problem, I'm still getting no parameterless constructor defined for this object .... do I have to put appId in the constructor?
@No1_Melman, context? On which line are you getting this message, for what object?
Nope, its fine, the ViewModel i was passing back to the Action had no parameterless constructor, so I created one and it works :)

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.