Add a text tag around it, as the compiler considers your JavaScript to be Razor syntax. When you do this, you need to add @ to the TempData call.
@section script { <script type="text/javascript"> $(document).ready(function () { @if (TempData["Message"] != null) { <text>showNotification('@TempData["Message"].ToString()');</text> } }); </script> }
Martin
source share