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. Custom error pages .Net [modified]

Custom error pages .Net [modified]

Scheduled Pinned Locked Moved Web Development
helpquestioncsharpjavascriptcss
3 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    markymark82
    wrote on last edited by
    #1

    Hi all, I have a custom 404 error page for my site, it is an aspx page as it uses the master template to retain site navigation etc. I have configured the web.config file, and so all un-found pages redirect to my 404 page just fine, but for directories not found it doesn't work, which I get just fine. What I have done then is to change the error page that IIS serves up, telling it to point to my 404 page relative to the site root. This too works fine, but only for urls such as : www.mysite.co.uk/afakedir but for: www.mysite.co.uk/afakedir/ it screws up my links to js files and stylesheets etc. obviously because these are set to be relative to the path, which is changed when a trailing / is added. How do I get round this without putting in absolute links to my js and css files etc? They need to be relative as I don't want to be making changes between my development and live site and obviously the paths would be different. I'm sure i'm not the only person to have this problem, or have tried this, I just can't seem to find a solution that works all round. Any help would be appreciated, even just pointing me in the right direction :) --- What I forgot to mention is that I initially need this to work on iis6, but will need it to work on iis 7.5 also.. Many thanks.. Mark

    modified on Tuesday, April 6, 2010 5:02 AM

    T 1 Reply Last reply
    0
    • M markymark82

      Hi all, I have a custom 404 error page for my site, it is an aspx page as it uses the master template to retain site navigation etc. I have configured the web.config file, and so all un-found pages redirect to my 404 page just fine, but for directories not found it doesn't work, which I get just fine. What I have done then is to change the error page that IIS serves up, telling it to point to my 404 page relative to the site root. This too works fine, but only for urls such as : www.mysite.co.uk/afakedir but for: www.mysite.co.uk/afakedir/ it screws up my links to js files and stylesheets etc. obviously because these are set to be relative to the path, which is changed when a trailing / is added. How do I get round this without putting in absolute links to my js and css files etc? They need to be relative as I don't want to be making changes between my development and live site and obviously the paths would be different. I'm sure i'm not the only person to have this problem, or have tried this, I just can't seem to find a solution that works all round. Any help would be appreciated, even just pointing me in the right direction :) --- What I forgot to mention is that I initially need this to work on iis6, but will need it to work on iis 7.5 also.. Many thanks.. Mark

      modified on Tuesday, April 6, 2010 5:02 AM

      T Offline
      T Offline
      T M Gray
      wrote on last edited by
      #2

      Make all of your links relative to the root. Instead of things like ../styles/style.css use /styles/style.css.

      M 1 Reply Last reply
      0
      • T T M Gray

        Make all of your links relative to the root. Instead of things like ../styles/style.css use /styles/style.css.

        M Offline
        M Offline
        markymark82
        wrote on last edited by
        #3

        Hi ya, I have made them relative, but when the trailing / is on the end it thinks it's in a directory above where it is, and so the links fail. I even tried making the links server-side so that I can use href="~/Styles/StyleSheet.css" but the website thinks it is at root level, because that's where the 404 page is. When I view the source code for the page, the links appear as www.mysite.co.uk/afakedir/Styles/stylesheet.css it turns out it's not just the css and js files, but all other links have the fake directory appended to the beginning of it. (I hope that made sense...) It's left me very confused, I thought it was going to be very simple. Thanks for the advice :) Mark

        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