7
I’m having trouble sending this type of input in the input field: &&&&%$&#_(@)(#_!**@#)24 R87R XDHNSIFN 89Q7201784
Dangerous Resquest.Form Error occurs.
Error message:
Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TesteInputValidation.Models;
namespace TesteInputValidation.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(Cartao t)
{
var teste = t;
return View();
}
}
}
Model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace TesteInputValidation.Models
{
public class Cartao
{
public string CartaoBeneficiario { get; set; }
}
}
View
@model TesteInputValidation.Models.Cartao
@{
ViewBag.Title = "Home Page";
}
<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="row">
@using (Html.BeginForm(null, null, FormMethod.Post, new {@id = "frmFiltro", @class = "smart-form"}))
{
@Html.TextBoxFor(model => model.CartaoBeneficiario, new { @class = "form-control", @id = "txtNumeroCartao" })
<footer>
<button id="enviar" type="submit" class="btn btn-primary wait-process">Enviar</button>
</footer>
}
</div>
If I take the validation will take all validations from Data Annotation?
There is a way to treat this error correctly?
But isn’t there any way you don’t need to disable Validate Input? some kind of Script or function in Razor that decodes html ?
– Mr Anderson