0

I've used this info but its not working

How to Create Session Variable in JavaScript MVC3 Razor View engine .cshtml

Any idea?

This is my SetVariable ActionResult:

Public Function SetVariable(key As String, value As String) As ActionResult
    Session(key) = value
    Return Me.Json(New With { _
        Key .success = True _
    })
End Function

This is the JS function which calls the previous function

function Comprobacion2(s, e) {
        
        $(function () {
            $.post('/Home/SetVariable',
                   { key: "cadena", value: "Nueva" }, function (data) {
                       alert("Exito, cambio realizado " + '@Session("cadena")');
                   });
        });

    }

2
  • Does the function gets called? If it does, I'm pretty sure the Session variable is getting modified. Commented Nov 6, 2015 at 13:17
  • Yes, this js function call the SetVariable function (Edited original post) Commented Nov 9, 2015 at 9:36

1 Answer 1

0

I solved my issue using another function:

function Comprobacion3(s, e) {
        $(function () {
            $.get('/Home/GetVariable',
                   { key: "cadena" }, function (data) {
                       alert(data);
                   });
        });
    }

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

Comments

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.