Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Best URL/File Structure Practices?

Best URL/File Structure Practices?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethostingcloudhelp
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dralken
    wrote on last edited by
    #1

    I'm pretty new to ASP.NET, building my first simple website using C#/RazorV2, hosting it on the free Windows Azure site. I've found plenty of articles explaining how the URL structure works, and I've mostly got it figured out, but what I'm wondering is, what's the best/safest/most correct way of doing it? Is it better to actually have multiple smaller files to handle things? Or is it "OK" or accepted to have one file handle several things? For example, I'm building a simple blog web app, and right now I'm using single files to handle multiple sections, like I have a Blog.cshtml:

    if (urlDepth > 0) {
    renderPost = new List();
    switch (UrlData[0]) {
    case "Post":
    int _postID = 0;
    _postID = Convert.ToInt32(UrlData[1]);
    renderPost.Add(blogRender.ShowSinglePost(_postID));
    Page.Title = renderPost[0].Name;
    break;
    case "Category":
    BlogCategory selCat = catDisplay.GetCategory(UrlData[1]);
    Page.Title = selCat.Name;
    renderPost = blogRender.PostsInCategory(selCat.ID);
    break;
    }
    } else {
    renderPost = blogRender.MultiplePosts(10);
    }

    I know it's a bit crude as it is, but it's a work-in-progress, I plan on making it more failsafe as I go. But before I get too deep into it and possibly end up needing to tear it apart, would it be better to actually just make a folder named Blog, and have separate Post.cshtml and Category.cshtml files to handle their respective areas? Figure it's best to know now so I can fix it if need be, rather than find out down the road that I messed up and have to try and pry apart the code. If someone wants to see it in action to get a better idea of what I'm doing, it's currently at http://vouksh.azurewebsites.net/

    M 2 Replies Last reply
    0
    • D Dralken

      I'm pretty new to ASP.NET, building my first simple website using C#/RazorV2, hosting it on the free Windows Azure site. I've found plenty of articles explaining how the URL structure works, and I've mostly got it figured out, but what I'm wondering is, what's the best/safest/most correct way of doing it? Is it better to actually have multiple smaller files to handle things? Or is it "OK" or accepted to have one file handle several things? For example, I'm building a simple blog web app, and right now I'm using single files to handle multiple sections, like I have a Blog.cshtml:

      if (urlDepth > 0) {
      renderPost = new List();
      switch (UrlData[0]) {
      case "Post":
      int _postID = 0;
      _postID = Convert.ToInt32(UrlData[1]);
      renderPost.Add(blogRender.ShowSinglePost(_postID));
      Page.Title = renderPost[0].Name;
      break;
      case "Category":
      BlogCategory selCat = catDisplay.GetCategory(UrlData[1]);
      Page.Title = selCat.Name;
      renderPost = blogRender.PostsInCategory(selCat.ID);
      break;
      }
      } else {
      renderPost = blogRender.MultiplePosts(10);
      }

      I know it's a bit crude as it is, but it's a work-in-progress, I plan on making it more failsafe as I go. But before I get too deep into it and possibly end up needing to tear it apart, would it be better to actually just make a folder named Blog, and have separate Post.cshtml and Category.cshtml files to handle their respective areas? Figure it's best to know now so I can fix it if need be, rather than find out down the road that I messed up and have to try and pry apart the code. If someone wants to see it in action to get a better idea of what I'm doing, it's currently at http://vouksh.azurewebsites.net/

      M Offline
      M Offline
      Marco Bertschi
      wrote on last edited by
      #2

      IMO it is okay to handle differrent permission for the same thing, i.e. the admin can delete a blog post on the same page as a user can view blog posts. I would not use the same page for Categories and blog posts because they are two different things. The more features/things which can be display (categories, blog posts etc.) you add to a page the more crowded the pages' code behind gets and sooner or later you will loose the overview.

      cheers Marco Bertschi


      Software Developer & Founder SMGT Web-Portal CP Profile | Twitter | Facebook | SMGT Web-Portal


      FizzBuzz - Gary Wheeler

      1 Reply Last reply
      0
      • D Dralken

        I'm pretty new to ASP.NET, building my first simple website using C#/RazorV2, hosting it on the free Windows Azure site. I've found plenty of articles explaining how the URL structure works, and I've mostly got it figured out, but what I'm wondering is, what's the best/safest/most correct way of doing it? Is it better to actually have multiple smaller files to handle things? Or is it "OK" or accepted to have one file handle several things? For example, I'm building a simple blog web app, and right now I'm using single files to handle multiple sections, like I have a Blog.cshtml:

        if (urlDepth > 0) {
        renderPost = new List();
        switch (UrlData[0]) {
        case "Post":
        int _postID = 0;
        _postID = Convert.ToInt32(UrlData[1]);
        renderPost.Add(blogRender.ShowSinglePost(_postID));
        Page.Title = renderPost[0].Name;
        break;
        case "Category":
        BlogCategory selCat = catDisplay.GetCategory(UrlData[1]);
        Page.Title = selCat.Name;
        renderPost = blogRender.PostsInCategory(selCat.ID);
        break;
        }
        } else {
        renderPost = blogRender.MultiplePosts(10);
        }

        I know it's a bit crude as it is, but it's a work-in-progress, I plan on making it more failsafe as I go. But before I get too deep into it and possibly end up needing to tear it apart, would it be better to actually just make a folder named Blog, and have separate Post.cshtml and Category.cshtml files to handle their respective areas? Figure it's best to know now so I can fix it if need be, rather than find out down the road that I messed up and have to try and pry apart the code. If someone wants to see it in action to get a better idea of what I'm doing, it's currently at http://vouksh.azurewebsites.net/

        M Offline
        M Offline
        Marco Bertschi
        wrote on last edited by
        #3

        But the page looks good!

        cheers Marco Bertschi


        Software Developer & Founder SMGT Web-Portal CP Profile | Twitter | Facebook | SMGT Web-Portal


        FizzBuzz - Gary Wheeler

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups