I have an asp.net mvc 1.0 site that serves some content from a level 2 hierarchy / Category / articles
When everything works correctly, the article is mapped to the view and the view is visualized. However, when the URL meets the routing condition, but the view does not exist, an exception occurs that cannot be blocked in the controller action.
Routing:
routes.MapRoute(
"Article",
"{category}/{article}.aspx",
new { controller = "MyController", action = "Article" }
);
MyController action:
public ActionResult Article(string category, string article)
{
string path = string.Format("~/Views/{0}/{1}.aspx", category, article);
ViewResult vr = View(path);
return vr;
}
However, when the view is not found, it is generated System.InvalidOperationException, which I cannot catch in the Action Controller.
: System.InvalidOperationException: '~/Views/my-category/my-article-with-long-name.aspx' . : ~/Views/-/-- name.aspx
Application_Error() global.asax.cs, :