Project Structure

Topics: Developer Forum
Jan 12, 2009 at 9:21 AM
Where should the views be stored in the project structure?

How can I make it so that users can't navigate directly to the view, and get an error "Value cannot be null. Parameter name: item".

I tried putting them in a seperate folder, and restricting access but then n2cms won't render the pages.

For the moment I'll just stick them in a folder which people don't know about (hopefully).

How is everyone else storing the views in their project structure?
Jan 12, 2009 at 7:56 PM
I've used /Templates/UI/Views/. In my case I'm not very worried about people accessing them directly since they would either throw an exception or not be much use without an actual item.

Is this about ASP.NET MVC by the way? There I've seen the project template uses a not found handler that disallows access to the templates directly.
Jan 19, 2009 at 8:17 AM
One way of preventing the exception from getting thrown is to test for null.

        protected void Page_Init(object sender, EventArgs e)
            if (CurrentItem == null)

Ok, your still going to get to get Thread.Abort exception. So maybe a Server.Transfer("~/index.aspx"); And rather than going to index.aspx can go to content not found page.

And rather than putting this on every page can stick it in a base page.