url rewriting with no extension in url

G

Guest

//reposting because of spelling mistake in "rewritting" in original post

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
 
G

Guest

Unless you map the wildcard * to the ASP.NET ISAPI dll, which would make all
requests - even for images - go through ASP.NET and "hit" your urlrewriting
code, no.

You can use rewriting at the ISAPI level instead, if that's your goal. There
are several products out there, (ISAPI_REWRITE LITE is one that's free).
However, if you are in a shared hosting environment, it wouldn't help since
you'd need access to the desktop to install in IIS.
Peter
 
G

Guest

Peter -

Thanks for you advice.
I will research ISAPI_REWRITE LITE

Also there was another suggestion by Gregory but I am in the process of
registering to Visual Studio Magazine to see the article refered to in the
link below:

Thanks for your help. I will give you more feedback soon.
Also can you please tell me your thoughts on Gregory's suggestion?

Thanks,
Leo
201-923-9595


By: Cowboy (Gregory A. Beamer) In:
microsoft.public.dotnet.framework.aspnet


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

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

George Ter-Saakov

Without messing with ISAPIs you can not do that.

You can have a workaround by specifying your custom 404 page in IIS settings
and setting it to be (let say) 404.aspx
then you can do whatever you want.

The key is to transfer control to ASP.NET engine. Unfortunately the only way
to do it is to use aspx extensions in your requests.
But be ready that some pictures you forgot to upload on a server will be
triggering the same 404.aspx page.


George.
 
G

Guest

What about this:

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...ine-behavior-using-a-virtualpathprovider.aspx]
 
F

Flinky Wisty Pomm

You probably *could* use a VPP, but I think it's overkill. It has its
own set of drawbacks (no precompilation for one). I'm mostly using it
because - damn it - it's hella cool, and I want to use it as a test-bed
for creating RESTful json web services at some point in the future.

-- flink
What about this:

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...ine-behavior-using-a-virtualpathprovider.aspx]


George Ter-Saakov said:
Without messing with ISAPIs you can not do that.

You can have a workaround by specifying your custom 404 page in IIS settings
and setting it to be (let say) 404.aspx
then you can do whatever you want.

The key is to transfer control to ASP.NET engine. Unfortunately the only way
to do it is to use aspx extensions in your requests.
But be ready that some pictures you forgot to upload on a server will be
triggering the same 404.aspx page.


George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top