1
I’m trying to send a message from Controller to View using Viewdata, but it’s not displaying the message.
When I click on the "Check" button of the View it is to call the method Verificar() from Controller, is calling correctly, and returns the message from Viewdata.
I debugged the code and the following error is appearing in Viewdata:
Controller
public ActionResult Verificar()
    {
        string Feedback = string.Empty;
        var DadosTemporarios = NDados.BuscaScanIDTemporaria();
        var DadosVulnExistentes = NDados.BuscaScanIDVulnExistentes();
        if (DadosTemporarios.ScanID == DadosVulnExistentes.ScanID)
        {
            Feedback = "ScanID Iguais!";
        }
        else
        {
            Feedback = "ScanID Diferentes!";
        }
        ViewData["Feedback"] = Feedback;
        return View("Index", ViewData["Feedback"]);
    }
View
<script>
function VerificaDados() {
    $.ajax({
        url: '/UploadDados/Verificar',
        type: "GET"
    });
};
</script>
<div class="container">
    <h3><strong>Importar Tabela de Vulnerabilidades</strong></h3>
    <hr />
    @using (Html.BeginForm("Index", "UploadDados", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        <div class="form-group">
            <label for="anexo">Anexar Arquivo CSV</label>
            <input type="file" id="FileUpload" name="FileUpload" />
        </div>
        <p>@Html.Encode(ViewData["Feedback"])</p>
        <p>
            <button class="btn btn btn-warning" type="submit" onclick="submitForm()">Upload</button>
            <button class="btn btn btn-warning" type="button" onclick="VerificaDados()">Verificar</button>
        </p>
    }
</div>
						
You will show the Viewdata message only when you click the check button ?
– Thiago Friedman
After calling Check and return to Index method.
– Italo