There is a Common.cshmtl file containing Razor helpers in App_Code folder of my ASP.NET MVC 5 project.

The page view (let it be called Production.cshtml) uses lots of helpers from Common.cshmtl in the way like:

@Common.Helper1();
...
@Common.Helper2();
...
@Common.Helper3();

It is following the recommendations from http://www.asp.net/web-pages/overview/ui,-layouts,-and-themes/creating-and-using-a-helper-in-an-aspnet-web-pages-site

Due to the bug in application code I can see that 2 almost equal AJAX requests are performed after a button click on a page.

I'm getting an error

An exception of type 'System.InvalidOperationException' occurred in mscorlib.dll but was not handled in user code.

An error also claims that the code is trying to modify the collection inside foreach operator. Here it looks like a normal error of application code.

But when debugging the code to find a certain error I can see that it breaks in some very random place of Product.cshtml not connected to the foreach at all. No foreach could be found neither in upper-level and bottom-level files. Also when trying to debug again (without modifications of course) - I can see that the break occured this time in another file - in Common.cshtml ! Repeating again and again prooves this strange behavior.

What could be the reason?

Related posts

Recent Viewed