location.href = '@Url.Action("PageIndex","Home",new {id = ViewBag.swfLoc })';

Above code snippet is resides in the <script> tag of my razor View *.cshtml file.

What I ask is : Can I add some code logic in side Url.Action function parameter.

e.g

 location.href = '@Url.Action("PageIndex","Home",new {id = ViewBag.swfLoc.isEmpty() ? "other" : "this" })';

Other than declare a variable inside top razor block @{} because I don't want to declare many dummy variables.

If possible, how? Use string of C# or JS string for this?

Thanks in advance!

Related posts

Recent Viewed