Problems with Theme and Context.RewritePath()

M

MatsL

Hi,
I'm using Context.RewritePath() in a HttpModule to get url rewriting done.
http://localhost/Web1/articles ->
http://localhost/Web1/Default.aspx?m=articles

But I'm having problems with Themes when I'm using that.
The problem rises when my url ends with a '/'.

Example:
http://localhost/Web1/articles
works fine

but
http://localhost/Web1/articles/
doesn't.

My path's to my theme resources are messed up, being appended to the
url, like this:
http://localhost/Web1/articles/App_Themes/AnnorlundaArbetsliv/Articles.css

Has anyone else had this problem (and hopefully fixed it :)

Btw, I rewrite the path back to the original one in Page.OnPreInit() to
get my postbacks go to the rewritten url...

Best regards,
Mats Lycken
 
K

Kevin Jones

I had this exact problem. I fixed it by detecting the trialing '/' and
redirecting to the same URL without the '/'. Not very elegant but it worked,

Kevin Jones
 
S

Steven Cheng[MSFT]

Hello Mats,

Does Kevin's sugegstion helpful for your case?

As for the Rewriting, are you only using a HttpModule to perform the
urlrewriting? Based on my understanding, ASP.NET runtime will only receive
request which is targeting the ASP.NET specific document extensions (like
.aspx, .ascx..... ). And for the below style request path, IIS won't
forward it to ASP.NET runtime, have you also used other rewrite components
or are you only testing in VS 2005 test webserver?

http://localhost/Web1/articles
http://localhost/Web1/articles/

In addition, here is a web article which has mentioned a theme's path
rebasing issue when using URL Rewriting, it indicate that we can use the
HttpContext.RewritePath's override version to choose not rebase the url:

http://davidhayden.com/blog/dave/archive/2006/01/14/2693.aspx

Anyway, please feel free to let me know if there is anything I missed or if
you have any particular concerns in your scenario.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Forum statistics

Threads
473,787
Messages
2,569,629
Members
45,329
Latest member
InezZ76898

Latest Threads

Top