.NET MVC – Illegal characters in path

Render a ASP.NET MVC Razor view with a model from the controller.

Error / Exception
System.ArgumentException: Illegal characters in path.

The model from the controller was returning JSON and the view had declared “@model string” to handle the JSON.

Updates in both controller and view. Change controller return type from string to the object.

Original: return View(JsonConvert.SerializeObject(List));
Change to: return View(List);

Original: @model string
Change to: @model List<object>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.