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. General Programming
  3. C#
  4. Relative URLs in Code-Behind

Relative URLs in Code-Behind

Scheduled Pinned Locked Moved C#
helpcsharpvisual-studiotutorialquestion
2 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.
  • C Offline
    C Offline
    Colin Pace
    wrote on last edited by
    #1

    Hi, I am implementing a mechanism that check a user is logged in before showing the aspx pages. I have tried to implement this in the code behind of the master page of the restricted pages. In case there is no-one logged in the page must redirect to the appropriate "No-Rights" page. The problem is that the master page can be used by pages at different folder levels. How to redirect the response to the correct URL of the page? How to specify the URL relative from the web-application root? Another typical problem here is that when debugging using Visual Studio, the pages are relative to the localhost/PROJECT-NAME/pages. But when deployed the pages are placed directly under HOST/pages. Can anyone help? Thanks, Colin

    A 1 Reply Last reply
    0
    • C Colin Pace

      Hi, I am implementing a mechanism that check a user is logged in before showing the aspx pages. I have tried to implement this in the code behind of the master page of the restricted pages. In case there is no-one logged in the page must redirect to the appropriate "No-Rights" page. The problem is that the master page can be used by pages at different folder levels. How to redirect the response to the correct URL of the page? How to specify the URL relative from the web-application root? Another typical problem here is that when debugging using Visual Studio, the pages are relative to the localhost/PROJECT-NAME/pages. But when deployed the pages are placed directly under HOST/pages. Can anyone help? Thanks, Colin

      A Offline
      A Offline
      Adam R Harris
      wrote on last edited by
      #2

      First of all this should have been posted in the ASP.NET Boards[^]. From what I recall, you are going to have to use ~ to go to the root of the directory. i.e. localhost/Project-Name/Restricted/test.aspx = ~/Restricted/test.aspx so even if you were on localhost/Project-Name/Restricted/test.aspx you could reference to the login page with something like this (assuming your login page is in the root of the website), ~/login.aspx

      If at first you don't succeed ... post it on The Code Project and Pray.

      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