Last post Jul 10, 2015 11:07 PM by Iddy
Jul 09, 2015 11:59 PM|Iddy|LINK
I am developing a web site and one of my admin pages has about 1000 lines of C# code at the beginning of the page. It has become a little unwieldy and I would like to somehow organize it better. I have tried putting the code into separate cshtml files
and calling them using RenderPage. But some of the code doesn't seem to work when I do this. Please don't tell me I need to go to MVC because Web Pages and Webmatrix aren't designed for that kind of complexity. Because that will make me cry.
Jul 10, 2015 02:00 AM|Mikesdotnetting|LINK
Try shifting some of the code into functions: http://www.mikesdotnetting.com/article/173/the-difference-between-helpers-and-functions-in-webmatrix. That
way you can replace blocks of code with single function calls, and it makes your code more reusable.
Please don't tell me I need to go to MVC because Web Pages and Webmatrix aren't designed for that kind of complexity.
Jul 10, 2015 08:37 AM|wavemaster|LINK
I have some experience with large swaths of code on a single page reaching the point where it becomes too difficult to keep an overview.
Breaking it up in smaller pages bring complexity too, plus the overhead of extra queries needed to continue the code from the next page.
Also, if you ever decide to use Entity Framework you will regret those different pages.
Last, don't use WebMatrix, but use Visual Studio for working on your code, and keep WebMatrix in a separate window for the db work.
VS has many more capabilities to deal elegantly with large pages.
MVC adds so many complexities by itself, that you gladly deal with 10,000 lines of code in WebMatrix.
Jul 10, 2015 11:07 PM|Iddy|LINK
Thanks guys, for the quick response and great ideas.