Exception when i use the methods RenderBody() and RenderSection()
Hello,
When i use the methods @RenderBody() and @RenderSection() on my main view, it throws an exception saying that my view (and because of that, my page) cannot be requested directly because it calls the RenderBody method.
Now i have read through the get started tutorial and plenty of other documentation to get started on Umbraco MVC, but it seems like noone in this community is experiencing the same behavior.. Maybe you can help me point out what i am doing wrong? This is my markup:
The file "~/Views/Main.cshtml" cannot be requested directly because it calls the "RenderBody" method.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The file "~/Views/Main.cshtml" cannot be requested directly because it calls the "RenderBody" method.
It seems like i lost all my braincells during the Umbraco Festival today, i found the answer. In future reference if there is other people out there experiencing the same thing, you need to create a subtemplate to your main template, so you dont call your main template directly, exactly as it says, doh!
Am really pleased you posted this. Would have probabley take a long time to realize my mistake if you hadn't and I don't have the excuse of the Umbraco festival to fall back on.
When I call my master template directly, I would expect @RenderBody() to render an empty string.
I find that I can catch the exception myself in the master template. Still, I feel like replacing the exception with an empty string, is something that belongs inside of @RenderBody.
Exception when i use the methods RenderBody() and RenderSection()
Hello,
When i use the methods @RenderBody() and @RenderSection() on my main view, it throws an exception saying that my view (and because of that, my page) cannot be requested directly because it calls the RenderBody method.
Now i have read through the get started tutorial and plenty of other documentation to get started on Umbraco MVC, but it seems like noone in this community is experiencing the same behavior.. Maybe you can help me point out what i am doing wrong? This is my markup:
Edit, here is my exception:
Let me know if you need the stacktrace..
Regards and thanks in advance,
Mathias.
It seems like i lost all my braincells during the Umbraco Festival today, i found the answer.
In future reference if there is other people out there experiencing the same thing, you need to create a subtemplate to your main template, so you dont call your main template directly, exactly as it says, doh!
Am really pleased you posted this. Would have probabley take a long time to realize my mistake if you hadn't and I don't have the excuse of the Umbraco festival to fall back on.
Can u make it clear! i have tried as u said but no use!
Ravindra!
But does the throwing of an exception make sense?
When I call my master template directly, I would expect @RenderBody() to render an empty string.
I find that I can catch the exception myself in the master template. Still, I feel like replacing the exception with an empty string, is something that belongs inside of @RenderBody.
is working on a reply...