I work on an ASP.NET MVC 5 project.
I try to use razor syntax in script area on the cshtml page:
<script type="text/javascript">
var url = '@Url.Content("~/Account/Login/")';
@if (Request.IsAuthenticated)
{
url = '@Url.Content("~/Account/GetLayers/")';
}
</script>
But when I run the page I get on this row:
url = '@Url.Content("~/Account/GetLayers/")';
This error:
CS1012: Too many characters in character literal
So I tried this:
url = "@Url.Content("~/Account/GetLayers/")";
But now I get this error:
CS1002: ; expected
Any idea why my attempts above don't work?