473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Non-Existent folder urlrewrite without changing ISAPI

Hello,

The webhost that I have my asp.net website with does not allow me to
change the ISAPI handler for IIS, I am wondering if there is a way to
accomplish this without modifying the ISAPI handler.

a user goes to: http://www.mysite.com/username/

and it redirects to:

http://www.mysite.com/default.aspx?u=username

Now, I see you can do this with an HttpModule, but because of the fact
that the folder /username/ doesnt exist, IIS will throw a 404 error.

Is there anyway around this since I can't modify or add my own ISAPI
handler?

Apr 12 '06 #1
4 1548
HttpContext.RewritePath(string filePath, string pathInfo, string
queryString).

I call it in Application_BeginRequest (Global.asax.cs), and then in the
page load (default.aspx) write it back to the requested url. The code
is something like:

1) if the requested file is an ".axd" (resource handler request, such
as for freetextbox) then return without rewrite
2) check if requested physical page exists on the server, and if so
return without rewrite (to allow hardcoded pages to be accessible)
3) process the requested url and see if you know what it means. In
your case check the last folder name, look the user up, if they do not
exist, return without rewrite so a 404 error occurs. If they do exist,
call rewrite path with your new url.
4) you really should write the url back to the original in the page
load if you expect that page to post back to the server. Otherwise
when they post back they will not see your hackable (friendly) url in
the address bar anymore, but instead see your rewritten url.

This resource may help:
http://odetocode.com/blogs/scott/arc...01/01/509.aspx

You can look at my site to see the friendly urls in use. None of the
following pages physically exist on the server. They are all really
just default.aspx, which you can also access directly:
http://www.xquisoft.com/Products/VersionPolicy.aspx
http://www.xquisoft.com/Products/Portal/Overview.aspx
http://www.xquisoft.com/Products/Portal/Progress.aspx
http://www.xquisoft.com/home.aspx

are all really just...
http://www.xquisoft.com/default.aspx

Michael Lang
XQuiSoft LLC
(XQuiSoft Portal Framework)
http://www.xquisoft.com/

Apr 12 '06 #2
excellent!

I thought there was a way to do this without changing the ISAPI
handler. I cringe at the thought :)

Now, one more question.

This is one of first asp.net 2.0 apps, up to this point they were all
v1.1

I noticed in asp.net 2.0 there is no global.asax.cs, how do i add this
functionality to the Authenticate_Request with no Global.asax?

thanks alot!

Sean

Apr 12 '06 #3
I was answering for .net 1.1 I found an article for easier url
rewriting in .net 2.0. It's not as good as the route I've mentioned
earlier (check out the article comments). However, it may be fine for
your situation?
http://pietschsoft.com/Blog/Post.aspx?PostID=715

There is a global.asax in 2.0. You may have to add it manually.

Apr 12 '06 #4
actually the odetocode link you gave me earlier has a link to C# 2005
code, which explains it in framework 2.0.

the previous example is not very scalable as they have all the entries
hard coded into the web.config.

I beleieve the original solution would be perfect! thanks

sean

Apr 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: lothar | last post by:
re: 4.2.1 Regular Expression Syntax http://docs.python.org/lib/re-syntax.html *?, +?, ?? Adding "?" after the qualifier makes it perform the match in non-greedy or minimal fashion; as few...
5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
22
by: Steve - DND | last post by:
We're currently doing some tests to determine the performance of static vs non-static functions, and we're coming up with some odd(in our opinion) results. We used a very simple setup. One class...
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
14
by: Patrick Kowalzick | last post by:
Dear all, I have an existing piece of code with a struct with some PODs. struct A { int x; int y; };
11
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.