ViewData is not displaying a post

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 Verificar() method of the Controller, it is calling correctly, and returns the ViewData message.

I've debugged the code and the following error is appearing in the ViewData:

Controller

publicActionResultVerificar(){stringFeedback=string.Empty;varDadosTemporarios=NDados.BuscaScanIDTemporaria();varDadosVulnExistentes=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>
    
asked by anonymous 08.09.2015 / 21:58

3 answers

1

Why use Html.Encode?

Use @ViewData ["Feedback"]

    
09.09.2015 / 03:18
1

Try to use it directly:

@ViewData["Feedback"]
    
12.11.2015 / 16:05
0

Try this way:

<p> <%: ViewData["FeedBack"] %> </p>

otherwise this way:

<p> <%= ViewData["FeedBack"] %> </p>
    
08.09.2015 / 22:09