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. removing aspx extension

removing aspx extension

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netcomhelpquestion
1 Posts 1 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.
  • B Offline
    B Offline
    benams
    wrote on last edited by
    #1

    Hi, I want to remove the extension of my asp.net webpages(I have a webapplication). I've read some guidelines about the issue but I've found some simple ways to do it. I've tried adding the following lines to my web.config file:

    I have also tried to add this function to Application_BeginRequest in my global.asax file:

    string curruntpath = Request.Path.ToLower();
    curruntpath = curruntpath.Trim();
    if (curruntpath.EndsWith(".aspx"))
    {
    string finalurl = curruntpath.Substring(curruntpath.Length - 5, 5);
    HttpContext.Current.RewritePath(finalurl);
    }

    In the first case, when I type "www.site.com/page" I'm being redirected to "www.site.com/page.aspx"(which is my wanted page), but when I type "www.site.com/page.aspx" I want the shown URL to be "www.site.com/page", and it doesn't happen. In the second attempt I just can't get any page when typing "www.site.com/page.aspx". What should I do in order to solve it?

    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