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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to access user name from url

how to access user name from url

Scheduled Pinned Locked Moved ASP.NET
questiondatabasecomsysadminhelp
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.
  • D Offline
    D Offline
    dipak dipak
    wrote on last edited by
    #1

    Dear all, I want to access user name from the url written like this format http://www.codeproject.com/username1 user will enter his user name after website name. Remember that user will not enter user name as a query string like http://www.codeproject.com/username?username1 (I don't want this type of entry with url by user) when i am using this (http://www.codeproject.com/username1) type of url I have tryed to access user name from global.aspx -Application_BeginRequest event. i have searched that after the website name if the string (here username1) is not with . (i am not permitting to use . while user name created) it will redirect to download page with query string. like this: string TheRequestUrl = ""; string theurl = HttpContext.Current.Request.Path; string theFileName = theurl.Substring(theurl.LastIndexOf("/") + 1); if (!theFileName.Contains(".")) { TheRequestUrl += "Download.aspx?requestUser=" + theFileName; Response.Redirect(TheRequestUrl); } It is working properly on the local server. but on the server it redirect to 404 (page not found) page. not running the Application_BeginRequest event. Than what is the best way to achive this. Please help me

    Dipak

    C 1 Reply Last reply
    0
    • D dipak dipak

      Dear all, I want to access user name from the url written like this format http://www.codeproject.com/username1 user will enter his user name after website name. Remember that user will not enter user name as a query string like http://www.codeproject.com/username?username1 (I don't want this type of entry with url by user) when i am using this (http://www.codeproject.com/username1) type of url I have tryed to access user name from global.aspx -Application_BeginRequest event. i have searched that after the website name if the string (here username1) is not with . (i am not permitting to use . while user name created) it will redirect to download page with query string. like this: string TheRequestUrl = ""; string theurl = HttpContext.Current.Request.Path; string theFileName = theurl.Substring(theurl.LastIndexOf("/") + 1); if (!theFileName.Contains(".")) { TheRequestUrl += "Download.aspx?requestUser=" + theFileName; Response.Redirect(TheRequestUrl); } It is working properly on the local server. but on the server it redirect to 404 (page not found) page. not running the Application_BeginRequest event. Than what is the best way to achive this. Please help me

      Dipak

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Sounds like your server is not configured properly or doesn't have all your code uploaded to it. Are you sure download.aspx is present ? What if you type in the new URL directly ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      D 1 Reply Last reply
      0
      • C Christian Graus

        Sounds like your server is not configured properly or doesn't have all your code uploaded to it. Are you sure download.aspx is present ? What if you type in the new URL directly ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        D Offline
        D Offline
        dipak dipak
        wrote on last edited by
        #3

        Hello Sir, Thank you for reply. :-O download.aspx is present on the server. and it is opening properly when typeing the url manually on ther browser. But it may be server is not configured properly. On the control panel of this website a error 404 (page not found) is set to a html page by the hosting provider (godaddy.com). And that page is showing while i am trying that code. There are other options of 404 Error Behavior are: Use home page: Use custom page: If i set a custome page to a aspx page. I think it will open but where i wil loose the username (here username1). so how to solve this?

        Dipak

        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