简体   繁体   中英

How MVC razor manages TempData value at the client side?

Currently I have started using MVC 4 Razor. I want to know that "Where TempData is handled if assign its value in javascript?"

For example.

<script type="text/javascript">                        

        function removeTempDataValue()
        {
            @{TempData["a"] = null;}
            @{TempData["b"] = null;}
        }
    </script>

Now in this case, I will call removeTempDataValue() function on click of one div. So i want to know that how MVC4 razor will set TempData 's value.

So how it will manage TempData 's value client side?

So i want to know that how MVC4 razor will set TempData's value.

TempData is purely server side. So when you do that you are basically removing the value at the server. Javascript runs much later, on the client. Things like click events run on the client and you cannot manipulate TempData at all.

So how it will manage TempData's value client side?

It won't manage anything client side. If you want to change some value in TempData this can only happen at the server side. If you want to modify some server side value from the client you could use an AJAX request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM