Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

Querystring Values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roshawn Dawson - 18 Jul 2005 03:48 GMT
Hi,

While browsing the web, I've noticed that a lot of websites have values
in the url without any file extensions mentioned.  Consider this (fake) url:

http://www.yourdomain.com/article/1

It seems that the "1" is actually a querystring value. I always thought
that you must first specify a file with a valid extension and then
append the querystring value, like this:

http://www.yourdomain.com/article/somepage.aspx?id=1

I'd sure like to get my urls to appear like the first one. Is there any
method that can be used to get the desired result in ASP.NET,
preferrably without too-too much hasle?

Thanks,
Roshawn
Greg W - 18 Jul 2005 04:47 GMT
in your example, 1 would be a folder.  Inside that folder he would have a
file like default.asp, index.html, etc. so that it could also look like
http://www.yourdomain.com/article/1/ or
http://www.yourdomain.com/article/1/index.html.

As far as querry strings, if you dont like them, consider using hidden fields
to send the data if you don't like them showing.

>Hi,
>
[quoted text clipped - 15 lines]
>Thanks,
>Roshawn
Roshawn Dawson - 18 Jul 2005 05:01 GMT
Thank you.

Roshawn

> in your example, 1 would be a folder.  Inside that folder he would have a
> file like default.asp, index.html, etc. so that it could also look like
[quoted text clipped - 3 lines]
> As far as querry strings, if you dont like them, consider using hidden fields
> to send the data if you don't like them showing.
jasonkester - 18 Jul 2005 18:10 GMT
Often, a site will have a filter sitting in front of the webserver that
intercepts requests and reformats them.  For IIS, this is often done
with ISAPI.

Basically, you'll write a little C++ or Perl program that takes strings
like #1 below, and turns them into #2 below.  This was pretty popular
back in the day, but has fallen out of favor lately.  Probably because
ASP.NET doesn't do it for you, and you can't write ISAPI filters in C#.

1. http://www.yourdomain.com/article/1 and
2. http://www.yourdomain.com/article/somepage.aspx?id=1

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
Roshawn Dawson - 19 Jul 2005 08:01 GMT
Thanks.  I sure don't like using ISAPI filters, since I wouldn't have
physical access to the production web server.

However, isn't it possible to achieve the same thing using either an
httphandler or httpmodule?

Roshawn

> Often, a site will have a filter sitting in front of the webserver that
> intercepts requests and reformats them.  For IIS, this is often done
[quoted text clipped - 11 lines]
> Expat Software Consulting Services
> http://www.expatsoftware.com/
jasonkester - 19 Jul 2005 17:43 GMT
You can also pull it off with a custom 404 handler that looks at the
url the user was trying to get to, then reformats and redirects if it
matches a pattern.  That's how you usually end up doing this in
ASP.NET.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
Alan Silver - 24 Jul 2005 18:39 GMT
The example you showed would probably have been run through an ISAPI
filter as others have mentioned. That allows you to do pretty much what
you like with the incoming URL and send the request on to another URL,
including querystring values as you wish. URLReplace (by a Czec fellow
whose name escapes me at the moment) is a well known and free ISAPI
filter that does just this.

You can do the same in ASP.NET if you are prepared to live with an .aspx
ending on the URLs. Thus you can have ...

http://www.yourdomain.com/article/1.aspx

and have it mapped invisibly to ...

http://www.yourdomain.com/article.aspx?articleid=1

You need to write code in Application_BeginRequest to grab the
Request.Path and parse it for the info you want. Build the real URL,
including the querystring and then use Context.RewritePath to send the
request on to that URL.

You don't actually need HttpHandlers and so on. I have no idea why all
the examples of URL rewriting use them. It took me ages of confusion
before I discovered how simple URL rewriting really is.

Hope this helps.

>Hi,
>
[quoted text clipped - 16 lines]
>Thanks,
>Roshawn

Signature

Alan Silver
(anything added below this line is nothing to do with me)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.