asp.net url rewritng

gboy

Expert Member
Joined
Dec 27, 2005
Messages
1,610
hi

google is confusing me,

how would i go about a simple but effective way of implementing url rewriting with asp.net.

i have something like this now.

www.xyz.com?BID=388474&Pid=748574

what i would like is to read the BID (primary key) and then rewite it with the name. the query is simple enough but the rewriting to still hold the values, stumping me.

so at the end i would like www.xyz.com/boys/cars

any ideas / help
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
You'd need an ISAPI (?) dll to do the url rewrite, then your web page just handles the rest (getting the content etc)

Not sure url rewriting can be done with asp.net alone.

Why is google confusing you?

Google "url rewriting IIS6 like mod_rewrite Apache"

2nd link from the top should do it, and the one right after that one...
 

gboy

Expert Member
Joined
Dec 27, 2005
Messages
1,610
thanks, after 5 years in .net and asp it still drives me to drink some times. :D
 

FarligOpptreden

Executive Member
Joined
Mar 5, 2007
Messages
5,396
Well, if you're using IIS 6 and don't mind having a .aspx extension after each rewritten url, you can easily write an HTTP handler that does it for you. With IIS 7 the .aspx is a non-issue. I wrote a customizable HTTP handler that can rewrite urls based on REGEX stored either in a database or an XML file. It really isn't THAT difficult if you get the hang of the process.

So you don't need any ISAPI rewrite DLLs. Just an HTTP handler.
 

gboy

Expert Member
Joined
Dec 27, 2005
Messages
1,610
i am using IIS 7, How did you manage it, you see my problem is not so mutch the incominng url, but how would i Create it to give to people, and to use it to move from page to page. ie in the Server.transfer or Request.redirect methods in code ?
 

FarligOpptreden

Executive Member
Joined
Mar 5, 2007
Messages
5,396
Well, the handler I built makes it possible for you to have the original url template, as well as the rewritten url template. Each template contains a list of possible parameters that you could access and set via properties. So to access either the original or rewritten template of the url, you just pass in the access key it is stored as in the XML / DB. Neat, eh? :D

EDIT: I think you meant Response.Redirect though... ;)
 

iceman23

Senior Member
Joined
Oct 5, 2007
Messages
954
Well, if you're using IIS 6 and don't mind having a .aspx extension after each rewritten url, you can easily write an HTTP handler that does it for you. With IIS 7 the .aspx is a non-issue. I wrote a customizable HTTP handler that can rewrite urls based on REGEX stored either in a database or an XML file. It really isn't THAT difficult if you get the hang of the process.

So you don't need any ISAPI rewrite DLLs. Just an HTTP handler.

I have done it this way as well for IIS 6.

IIS 7 has a URL rewrite module so it is even easier.
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Not really interested in running Joomla or Wordpress on IIS. To each his own. Native PHP should stick with Apache, so if I feel like it I run Apache and IIS (IIS is a bitch though, so be careful).

Runs like a dream...

Anyway, these are for my old(er) ASP sites I want to SEO ;)

Looks like it will do the job nicely. Busy installing/playing with it now
 

IdlePhaedrus

Expert Member
Joined
Jan 31, 2005
Messages
1,582
Not really interested in running Joomla or Wordpress on IIS. To each his own. Native PHP should stick with Apache, so if I feel like it I run Apache and IIS (IIS is a bitch though, so be careful).

Runs like a dream...

Anyway, these are for my old(er) ASP sites I want to SEO ;)

Looks like it will do the job nicely. Busy installing/playing with it now

I have a number of sites that run on ASP.Net and PHP and am running them over IIS on a single server for testing over Telkom's crap ADSL.

It looks like IIS is better with PHP, than Apache with ASP, so I am stuck there at the moment.

Would be very interested to know your thoughts on IIRF after your testing.

I hope it does the job.
 
Last edited:

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Got stuck doing something else for the moment but have done a few tests (like the status thing) on different websites and the multisite thing works without too much headache or config. Previously had a free ISAPI that had to be configured for each and every website in one huge config file. And config file didn't auto-refresh or keep logs like this one.

BTW, I found that by running Apache that PHP is much easier to setup. All of the functions PHP has just *works* whereas I had to "coach" my IIS to get it limping along at least.

Testing my wordpress blog plugins and code on Apache with the url rewriting turned on as if I'm running it live is brilliant and a no brainer to setup.

Apache & ASP? No thanks. I'd rather stick with what the stuff was made for and test on. I'm only talking about it from a setup experience and I found it's less headache this way around
 
Top