locked
URL To Temporary/Non-Existent Profile Page RRS feed

  • Question

  • User253482888 posted

    Hi all,

    I really don’t know what to enter into a search engine for this so I hope my question makes sense. 

    I'm building a website that will include a profile page for each registered user (eg. domain.com/username), but I don’t want to actually create a copy of the profile page for each individual user.

    All of the users information is in a database so I can view each users details in a single template page (template.cshtml).

    What I want is to enter the web address (domain.com/user1) and for it display the page template.cshtml but showing the details from the database for user1

    I'm sure the mainstream sites must do something similar (like Facebook – I can’t imagine they have 500m individual profile pages).

    Id be grateful if someone can give me directions on how to achieve this, or tell me what its called so I can search it properly.

    Thank you

    Monday, September 21, 2015 7:26 AM

Answers

All replies

  • User379720387 posted

    No they don't.

    User data in tables and then a page that displays the information based on the userid you pass to the page.

    I think you are hung up on calling this a "template page" You create a page, whatever name, and design it to show the information you want.

    Inside that new page, you will query the db for the information you need for one user, and display that.

    http://www.asp.net/web-pages/overview/getting-started/introducing-aspnet-web-pages-2/getting-started

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 21, 2015 8:05 AM
  • User325035487 posted

    template.cshtml

    @{
    var userid = UrlData[0].ToString();
    var db=Database.Open("....");
    var sql = "SELECT * FROM UserProfiles WHERE UserID=@0";
    var userdata = db.QuerySingle(sql,userid);
    }
    <p>Name: @userdata.Name</p>
    <p>Address: @userdata.Address1</p>
    //and so on

    Tuesday, September 22, 2015 1:55 PM