locked
I would like to offer $50 for the help RRS feed

  • Question

  • User-548594559 posted

    Hello List,

    I posted the question earlier; so far I have not get solution yet.

    What I want to do is to make both Search page works with additional "Location" parameter. Also Advanced search page no longer requires the location parameter

    So I can create a home page with locations on it. When user clicks the location link on home page, it will pass that location value as a parameter to call search page. I want to customize the Classifieds site looks like www.craigslist.com

    The problem is I could not figure it out how to make search page works with “Location” parameter

    I would like to offer $50 box for anyone who can show me the sample code in C#. 

    If you are interested, please drop me an email peterxwang@hotmail.com 

    Thanks,

    Peter

    Sunday, April 6, 2008 7:48 AM

Answers

  • User1128022426 posted

    Good point..

    I think the problem with subdomains is that it's handled on the DNS level, so the request never makes it to the URL handler...

    In theory, you can configure your DNS to point all subdomains to to your main domain then you can start handling it with the rewriter....

    As far as extensions goes, this is a the same issue.... extensionless requests are not sent to the asp.net worker which means they are not sent to the rewriter... To change this you need IIS config changes therfore you need your own dedicated server to have access to do it....

    Daniel, how do you tell your re-writer to know the difference between

    http://www.detelli.com/Search.aspx and http://www.detelli.com/alabama.aspx

    Did you hardcode every possible state???

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 8, 2008 1:56 PM
  • User730446648 posted

    I use a seperate file to hold all the rewrites, most are dynamic, but as far as the states, and popular cities, I hard coded each and every one.

    This is my code line.

    <page urlmask="~/albuquerque_nm.aspx" url="~/Results.aspx?houses_for_rent_in=albuquerque&amp;c=30" mask="true" enabled="true" />

    It took a while, but well worth the time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 8, 2008 2:26 PM
  • User1128022426 posted

    You need to read that passed Querystring

    //

    string location=Request.QueryString["location"];

    if(location !=null)
    {
    AdSearchDataSource.SelectParameters["location"].DefaultValue=location;
    }

     I'm assuming you already made the necessary changes to the ObjectDataSource"AdSearchDataSource" in Search.aspx to accept the

    OR

    Modify AdSearchDataSource to the paramter read from the querystring...(Modify the control) and pick QS as the source of data.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 14, 2008 5:32 PM
  • User730446648 posted

    So I did it by making changes in only the codebehind for the search results page.

    It basically uses the advanced search function that is built in.

    As you can see I wanted houses for rent in the url so I used that instead of location, but you can use what ever you like.

    Also note that I use vb, so I used a convertor for assistance. This should be dead on, or at least really close.


    {
        string locQs = Request.QueryString("houses_for_rent_in");
        if ((locQs != null)) {
            _showCategoryBrowseForTopLevel = true;
            // pass it on to the hidden AdvSearch control (its stores most search parameters)
            AdvancedSearch.SetLocation(locQs);
            _advancedSearchInEffect = true;
            ViewState("advancedSearchInEffect") = true;
        }
    }

    Good Luck

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 14, 2008 7:02 PM

All replies

  • User730446648 posted

    Are you talking about how the category is coded into the url by default???

    Like this www.mysite.com/Search.aspx?c=5

    If that's correct I did it by just copying how category was done.

    Like this www.mysite.com/Search.aspx?c=5&location=city

    I now use a url rewriter to completly mask all the dynamic code.

    Take a look at my home page www.detelli.com

    Monday, April 7, 2008 1:17 AM
  • User-548594559 posted

    Thanks for your help. 

    I tried the two links related with mysite in your post,  I got 404 error.

    I think I am trying to do the samilar thing you did in your www.detelli.com site. What I want to do is to create an additional parameter called “Location” and pass it to default.aspx page. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    Here is what I did so far. I have downloaded Classifieds Site Starter Kit. I created a home page with multiple location links on it, just like craigslists.com does.
     
    When users click on the location link, "New York" for example, I will pass the location id to the default.aspx page (the original downloaded default page). The default page will only show the all ADs in that location, New York area, in this example. Also the search function will only search ADs related with New York location. The Advanced search will no longer need select location. It will search only in New York area as well. 

    Any ideas? 

    Thanks again,

    Peter 

    Monday, April 7, 2008 2:41 PM
  • User730446648 posted

    Not sure why you would get 404 on yours, it works by default, and I added location to mine.

    Working example:

    http://www.detelli.com/Results.aspx?c=46&houses_for_rent_in=bothell

    Which you can change bothell to seattle or any other city.

    I set my site up, so all the states are categories which is what the c stands for.

    As far as craigslist goes, it looks pretty simple, all they did was build a master list filled with the links to all the states and such.

    And had the links setup as subdomains.

    Look at your host provider for how to add subdomains.

    I'm not sure how craigslist remembers your preference, they don't seem to be loading a cookie, and that's what I would expect.

    But subdomains is your answer.

     

    Monday, April 7, 2008 6:43 PM
  • User1128022426 posted

    You would get 404 if the url rewriter is not configured correctly, or your rules are not set correctly...Double check that as well

    Monday, April 7, 2008 8:28 PM
  • User-548594559 posted
    It looks great!

    If I understand correct, for each location I need to create a separate sub-domain. For example I have to create two sub-domains, one for New York and the other for New Jersey. Also, for each sub-domain, I have to install a separate Classified Starter Kits. This solution seems work fine.

    But if I have locations for 50 states, I have to install seperate Starter Kits 50 times and I have to maintain 50 separate applications/databases. I am not sure it is the way craigslist.com handling it.

    Any suggestions,

    Thanks a lot for your help

    Peter

    Monday, April 7, 2008 9:39 PM
  • User730446648 posted

    Close, you don't install several kits.

    A sub domain is basically just a shortcut.

    For example if you set seattle.mysite.com as the shortcut to www.mysite.com/states/seattle

    It will all work the same.

    So you will need many folders, but not the entire kit.

    Further more, by default when the kit is linking to a picture or another page, it usually does it like this /images/pic1.jpg

    Since when you really think about it, seattle.mysite.com is not really on your root, you are going to need to enter the full paths.

    Like this http://www.mysite.com/images/pic1.jpg although some links may work just by adding ~/images/pics1.jpg

    I ultimatly decided to use the visionalyse url rewriter.

    Good Luck

     

    Monday, April 7, 2008 10:01 PM
  • User1128022426 posted

    Maybe i mis-understood what Daniel is explaining..but

    you DO NOT need several folders, you defeintly DO NOT need several versions of the application, you DO NOT have to create subdomains in your hosting control panel for each city.....

    the whole point of the URL re-writer is that you do not need to do any of that, instead you would create 'rules' which are regex matches that redirects your visitors to the same page passing different params..

    in http://www.love2trade.com , i use http://urlrewriter.net/ (its free). Daniel's uses visionalyse (Thanks! I never heard of it before) but it seems commercial (not too expensive so it might be worth it)...

     

    Good Luck!

    Tuesday, April 8, 2008 12:10 PM
  • User730446648 posted

    It all depends on which way he wants to go, if he chooses like craigs list

    state.mysite.com

    then as far as I know you have to use subdomains, I can't do this with my rewriter.

    Ash, will yours do that?

    For ease of use, I decided to use a url rewriter, but I have to code the link like this

    mysite.com/state.aspx

    (When I upgrade to a dedicated server I can then leave the .aspx off of the link)

     

    Tuesday, April 8, 2008 1:43 PM
  • User1128022426 posted

    Good point..

    I think the problem with subdomains is that it's handled on the DNS level, so the request never makes it to the URL handler...

    In theory, you can configure your DNS to point all subdomains to to your main domain then you can start handling it with the rewriter....

    As far as extensions goes, this is a the same issue.... extensionless requests are not sent to the asp.net worker which means they are not sent to the rewriter... To change this you need IIS config changes therfore you need your own dedicated server to have access to do it....

    Daniel, how do you tell your re-writer to know the difference between

    http://www.detelli.com/Search.aspx and http://www.detelli.com/alabama.aspx

    Did you hardcode every possible state???

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 8, 2008 1:56 PM
  • User730446648 posted

    I use a seperate file to hold all the rewrites, most are dynamic, but as far as the states, and popular cities, I hard coded each and every one.

    This is my code line.

    <page urlmask="~/albuquerque_nm.aspx" url="~/Results.aspx?houses_for_rent_in=albuquerque&amp;c=30" mask="true" enabled="true" />

    It took a while, but well worth the time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 8, 2008 2:26 PM
  • User-548594559 posted

    When I pass the location as an additional parameter to the search page, for example

    www.mywebsite.com/Search.aspx?c=5&location=NY,  what should I make a change in search .aspx.cs page in order to take this extra parameter and return the result only posted in New York area? <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p><o:p> </o:p><o:p></o:p> <o:p></o:p>Thanks a lot!

     

    Peter

    Monday, April 14, 2008 4:45 PM
  • User1128022426 posted

    You need to read that passed Querystring

    //

    string location=Request.QueryString["location"];

    if(location !=null)
    {
    AdSearchDataSource.SelectParameters["location"].DefaultValue=location;
    }

     I'm assuming you already made the necessary changes to the ObjectDataSource"AdSearchDataSource" in Search.aspx to accept the

    OR

    Modify AdSearchDataSource to the paramter read from the querystring...(Modify the control) and pick QS as the source of data.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 14, 2008 5:32 PM
  • User730446648 posted

    So I did it by making changes in only the codebehind for the search results page.

    It basically uses the advanced search function that is built in.

    As you can see I wanted houses for rent in the url so I used that instead of location, but you can use what ever you like.

    Also note that I use vb, so I used a convertor for assistance. This should be dead on, or at least really close.


    {
        string locQs = Request.QueryString("houses_for_rent_in");
        if ((locQs != null)) {
            _showCategoryBrowseForTopLevel = true;
            // pass it on to the hidden AdvSearch control (its stores most search parameters)
            AdvancedSearch.SetLocation(locQs);
            _advancedSearchInEffect = true;
            ViewState("advancedSearchInEffect") = true;
        }
    }

    Good Luck

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 14, 2008 7:02 PM
  • User-1329334484 posted

    Hi,

     How do you like what I did on Zikbay.com? I basiclly not use location anymore, but City, Country and State in the Query String. I use rewriter to mask it...

     Do the following to test:

    1) Click location link on Zikbay, change to country "Canada"

    2) Click Search. Now only ads from Canada will be shown.

     I am still working on it, as I want to show all ads (featured, popular etc on front page) based on selected location.

     I also do IP lookup for default country when user comes to the site first time. If no default Country "Show All" is selected...

     What do you think?

    Here is sample query: http://www.zikbay.com/Search.aspx?Country=US&State=GA 

     

    Wednesday, June 18, 2008 3:35 PM