I have a website hiearchy in mysql. I want to be able to take what they have for option1, option2, and option3 to go through the hiearchy and get the id.
I do not have access to iis. I know it is has iis 7 and Microsoft URL Rewrite is installed. I have read some solutions about going into iis 7 and using the * to handle folder urls. I don't have access to do that.
Is there a to handle what I'm looking for? I have created a httpmodule which works for .aspx extensions. I just need some way of doing this when I don't have extensions.
You can do this without having to access IIS by doing the following:
1. Create Global.asax in your website
2. In Application_BeginRequest you can add code to detect what URL has been specified and then do a rewrite to the actual URL you require to display that page, e.g.
string targetUrl = ""; // This needs to be the actual URL you're trying to map the friendly URL to, so you'll need some code to pair the two together
HttpContext.Current.RewritePath(targetUrl);
Remember you'll probably only want to do this for .aspx files! Css, images, etc., should probably be allowed to do their "usual" thing without rewriting.
Yeah, I have looked at the link alot. That works for .aspx, however I need it to work for extensionless urls. Approach 3 has a way to handle extensionless urls by putting a rewrite section within your web.config. The problem I have is that my website hiearchy
may have changed by addition and removal of pages.
I wonder if I could have all requests go through a single rewrite url. From there I could determine if it is extensionless and then at that point do a rewrite?
If you use an HttpModule instead of Global.asax, and register the HttpModule so that it runs in Integrated mode, (preCondition="integratedMode"), then the HttpModule will run with static files as well as with .aspx files -- that should include extensionless
URLs, too, provided you catch them early enough in the pipeline before IIS rejects them as 404 Not Found.
None
0 Points
3 Posts
url rewriting without having access to iis
Nov 09, 2009 10:47 AM|jschumann|LINK
I am trying to create a website that when a user types in a url like this http://www.something.com/option1/option2/option3 it uses rewriting to go to http://www.something.com/webpage.aspx?id=#.
I have a website hiearchy in mysql. I want to be able to take what they have for option1, option2, and option3 to go through the hiearchy and get the id.
I do not have access to iis. I know it is has iis 7 and Microsoft URL Rewrite is installed. I have read some solutions about going into iis 7 and using the * to handle folder urls. I don't have access to do that.
Is there a to handle what I'm looking for? I have created a httpmodule which works for .aspx extensions. I just need some way of doing this when I don't have extensions.
Thanks
Jeff
Member
600 Points
177 Posts
Re: url rewriting without having access to iis
Nov 09, 2009 11:03 AM|uid117455|LINK
Hi Jeff,
You can do this without having to access IIS by doing the following:
1. Create Global.asax in your website
2. In Application_BeginRequest you can add code to detect what URL has been specified and then do a rewrite to the actual URL you require to display that page, e.g.
Remember you'll probably only want to do this for .aspx files! Css, images, etc., should probably be allowed to do their "usual" thing without rewriting.
I found this article by Scott Guthrie to be very helpful with understanding URL rewriting: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
None
0 Points
3 Posts
Re: url rewriting without having access to iis
Nov 09, 2009 11:16 AM|jschumann|LINK
Yeah, I have looked at the link alot. That works for .aspx, however I need it to work for extensionless urls. Approach 3 has a way to handle extensionless urls by putting a rewrite section within your web.config. The problem I have is that my website hiearchy may have changed by addition and removal of pages.
I wonder if I could have all requests go through a single rewrite url. From there I could determine if it is extensionless and then at that point do a rewrite?
Contributor
3531 Points
869 Posts
Re: url rewriting without having access to iis
Nov 15, 2009 01:48 AM|RickNZ|LINK
If you use an HttpModule instead of Global.asax, and register the HttpModule so that it runs in Integrated mode, (preCondition="integratedMode"), then the HttpModule will run with static files as well as with .aspx files -- that should include extensionless URLs, too, provided you catch them early enough in the pipeline before IIS rejects them as 404 Not Found.
Ultra-Fast ASP.NET: Build Ultra-Fast and Ultra-Scalable web sites using ASP.NET and SQL Server
My blog: http://www.12knowmore.com