All about creating asp.net pages dynamically

Last post 05-26-2007 9:46 PM by jasonjanofsky. 3 replies.

Sort Posts:

  • All about creating asp.net pages dynamically

    05-26-2007, 1:33 PM
    • Member
      284 point Member
    • ejedspence
    • Member since 10-16-2004, 11:15 AM
    • Posts 61

    I want to create pages dynamically

    I am developing a site in which i want to display the data in a database in a page but i want to make the pages to be named the id of record i want to display.

    I want it in two different ways html and aspx.

    Some thing of that nature was done in Community starter kit but i really couldn't get it

    i need a good explanation on how to go about it.

    Thank you and expecting response very soon.

  • Re: All about creating asp.net pages dynamically

    05-26-2007, 2:17 PM
    • Member
      111 point Member
    • robi
    • Member since 10-19-2002, 8:08 AM
    • Posts 70

    I don't know how community server are doing it, but here is how i would probably do it.

    Just create a page that does exactly that, i mean gets the record displayed in it from the page name.

    To get the page name without the extension you can use:

    Dim CurrentFileName As String = IO.Path.GetFileNameWithoutExtension(Request.FilePath)

    After you have created this page, and checked that it is working, you can use the IO.File.Copy method to copy it to your new location,
    with a new name, the name of the id you want to display.

    IO.File.Copy("E:\SomeFolder\TemplateFile.aspx", "E:\OtherFolder\" & newId & ".aspx")

    Then to get the HTML version you need to save the output of the file.

    Read this on how to do that:

    http://west-wind.com/weblog/posts/481.aspx

    And then ofcourse you save that output to a file on the server, for that read this:

    http://aspalliance.com/152

  • Re: All about creating asp.net pages dynamically

    05-26-2007, 2:18 PM
    Answer
    • Contributor
      6,537 point Contributor
    • bitmask
    • Member since 07-29-2003, 3:18 PM
    • Citizen of the Earth
    • Posts 1,228

    One way to achieve this is to use a technique known as URL rewriting. There is a good article here: URL Rewriting in ASP.NET.

    Scott
    http://www.OdeToCode.com/blogs/scott/
  • Re: All about creating asp.net pages dynamically

    05-26-2007, 9:46 PM
    Answer
    • Member
      618 point Member
    • jasonjanofsky
    • Member since 03-19-2004, 2:57 PM
    • San Diego
    • Posts 140

    I second the url rewriting man, unless you absolutely have to have HTML.  With the rewriting you can also do stuff like, in the case of a news site, lookup http://www.mysite.com/2007/05 to bring up a list of all records in may 2007, or http://mysite.com/2007 for all articles in 2007, then if you get a .html, in your rewriting lookup, you can have the name of the file, before the .html be an ID number or something to pull it from your db.

    Also, when guys named Scott (Guthrie, Allen, Mitchell) who blog about ASP speak, we should all listen. 

    ...

    ...

     

    ... 

    Sometimes I want to change my name to Scott

    Feel free to hit me on MSN, I will try to help if I am not super busy.
Page 1 of 1 (4 items)