Results 1 to 8 of 8

Thread: Friendly URL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    71

    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

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    71

    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?

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  5. #5
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Friendly URL

    See this one also
    Please mark you thread resolved using the Thread Tools as shown

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    71

    Re: Friendly URL

    Okay.. I'l try em out!

  7. #7
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    307

    Re: Friendly URL

    if you need another option http://urlrewriter.net/

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Friendly URL

    putte,

    I am curious, how are you getting on? Have you had a chance to try any of them out?

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width