-
Friendly URL
Hi!
What is the most easy way to implement friendly URL:s? I code in VB and my server is Windows server 2003.
For example i have a car page that has id 5. My pages is now shown like this:
www.mysite.com/?id=5
But i want it too bee like this!
www.mysite.com/cars
My code looks like this now:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim pID As Integer
If Request.QueryString("id") = "" Then
pID = 1
Else
pID = Request.QueryString("id")
End If
Dim oConn As MySqlConnection = DBConn.getConn("mydb")
oConn.Open()
Dim getSQL As String = "SELECT * FROM pages WHERE nID = '" & pID & "' AND deleted = '0'"
Dim command As MySqlCommand = New MySqlCommand(getSQL, oConn)
Dim r As MySqlDataReader
r = command.ExecuteReader()
Label1.Text &= "<table cellpadding='5' cellspacing='0'><tr><td>"
While r.Read()
Label1.Text &= r("nContent")
End While
Label1.Text &= "</td></tr></table>"
r.Close()
oConn.Close()
oConn.Dispose()
End If
End Sub
Thank you
/Patrik
-
Re: Friendly URL
What you are talking about is essentially URL Rewriting.
There is a module that you can use for that here:
http://www.urlrewriting.net/149/en/home.html
If you are using IIS 7, then there is a built in module that can do this for you.
Or, if you are using ASP.Net 4.0, then there is a built in mechanism here as well:
http://msdn.microsoft.com/en-us/library/cc668201.aspx
Gary
-
Re: Friendly URL
I have looked at that module but its only in C#.. Even all the source files and documentation. And i use IIS6 and asp.net 3.5.
Can anybody that has implemented this in VB give me some help?
-
Re: Friendly URL
The UrlRwrite is simply a DLL that you would add to your project, the fact that it is implemented in C# shouldn't really matter to you.
Gary
-
Re: Friendly URL
-
Re: Friendly URL
-
Re: Friendly URL
if you need another option http://urlrewriter.net/ :)
-
Re: Friendly URL
putte,
I am curious, how are you getting on? Have you had a chance to try any of them out?
Gary