For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > October 2006 > url rewritting with no extension in url









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author url rewritting with no extension in url
rapiddata

2006-10-31, 7:06 pm

Is there a way to rewrite urls that have no extensions in the url, i.e. no
..aspx or no .html
like
http://www.mywebsite.com/username
to be rewritten as
http://www.mywebsite.com/pages/username.aspx

This is currently done in myspace.com where you can type
http://www.myspace.com/username

So far I have not found a solution to this problem.

When I go to IIS Management Console and try to do the
configuration extension mapping, it does not allow me to enter
..* or no extension for the mapping to the asp.net dll

Any help is greatly appreciated.

Thanks,
Leo
201-923-9595

Cowboy \(Gregory A. Beamer\)

2006-10-31, 7:06 pm

http://www.fawcette.com/vsm/2002_02...ine/columns/qa/

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

****************************************
*********
Think outside of the box!
****************************************
*********
"rapiddata" <rapiddata@discussions.microsoft.com> wrote in message
news:B50E7B0A-CF51-40A4-B5BF-519498C9EAE0@microsoft.com...
> Is there a way to rewrite urls that have no extensions in the url, i.e. no
> .aspx or no .html
> like
> http://www.mywebsite.com/username
> to be rewritten as
> http://www.mywebsite.com/pages/username.aspx
>
> This is currently done in myspace.com where you can type
> http://www.myspace.com/username
>
> So far I have not found a solution to this problem.
>
> When I go to IIS Management Console and try to do the
> configuration extension mapping, it does not allow me to enter
> .* or no extension for the mapping to the asp.net dll
>
> Any help is greatly appreciated.
>
> Thanks,
> Leo
> 201-923-9595
>



Flinky Wisty Pomm

2006-10-31, 7:06 pm

You can also get insanely clever with VirtualPathProvider. I'm
currently writing a blog engine with this (got to while away the hours
somehow) and it means I can do highly hackable URLS like:

/index
/index/2006
/index/2006/oct.rss
/posts/TitleOfPost
/posts/TitleOfPost.json
/posts/TitleOfPost/comments.rss(0,92)
/tag/SomeTag/
/tag/SomeTag/MicroSummary.atom

where the files referenced by those URLs don't exist, the
VirtualPathProvider can parse the URL and return an appropriate
VirtualFile.

In your case I think you could create VirtualPathProvider to do the
following:

is the URL in the pages directory?
no -> Pass it back to the default handler
yes ->
does the URL contain .aspx?
yes -> pass it back to the default handler
no -> pass url+".aspx" back to the default handler


There's a fairly relevant link here
[http://blogs.msdn.com/davidebb/arch...thprovider.aspx]

Let me know how you get on if you go down the VPP route, 'cos I'm
curious.

Cowboy (Gregory A. Beamer) wrote:
[color=darkred]
> http://www.fawcette.com/vsm/2002_02...ine/columns/qa/
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> http://gregorybeamer.spaces.live.com
>
> ****************************************
*********
> Think outside of the box!
> ****************************************
*********
> "rapiddata" <rapiddata@discussions.microsoft.com> wrote in message
> news:B50E7B0A-CF51-40A4-B5BF-519498C9EAE0@microsoft.com...

rapiddata

2006-10-31, 7:07 pm

Gregory -

Thanks for the advice but I can not read the other pages in the article past
page 1 because the article is from 2002 and I have a 2006 subscription to
msdn magazine.

Can you please provide the code?

Thanks,
Leo
201-923-9595

"Cowboy (Gregory A. Beamer)" wrote:

> http://www.fawcette.com/vsm/2002_02...ine/columns/qa/
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> http://gregorybeamer.spaces.live.com
>
> ****************************************
*********
> Think outside of the box!
> ****************************************
*********
> "rapiddata" <rapiddata@discussions.microsoft.com> wrote in message
> news:B50E7B0A-CF51-40A4-B5BF-519498C9EAE0@microsoft.com...
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com