___ ___ erkimt Error adding HttpPost the controller ______ qstntxt ___
I have a problem in time to add the attribute %code% on my controller. I mean, I can add the attribute without problems, but when I compile and go to the form registration I just can not access.
I get the following error:
Server Error in Application '/'.
Can not find the resource.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could not be removed, had its name changed, or is temporarily unavailable. Examine the URL and make sure that it is spelled correctly.
requested URL: / User / add
Version Information: Microsoft .NET Framework Version: 4.0.30319; ASP.NET:4.0.30319.33440
Also, when I take %code% % attribute, I can not see the registration form, but I can not do the insert in the bank.
When you add the HttpPost attribute in an action. It can only be accessed via the HTTP POST method.
If your intention is to only display the form. Do not decorate your method with no attributes, the default is GET.
What you can do is set an Add method with no attribute. This method will be accessed via GET and display the form.
Then you create a second method, for example AdicionarConfirmado, decorated with the attributes and HttpPost ActionName="Add"
The methods can no defined as follows
public ActionResult Adicionar()
{
}
[HttpPost]
[ActionName="Adicionar"]
public ActionResult AdicionarConfirmado(Cliente cliente)
{
}
Since your form that will save the record would look like this:
<form action="Adicionar" method="post"></form>