Is it possible to programatically change the Meta Tag HTML

Discussion in 'ASP .Net' started by Ross Culver, Aug 27, 2007.

  1. Ross Culver

    Ross Culver Guest

    I need to be able to create a new aspx file for new users that are specific
    and optimized for that user. For instance, Joe Blow clicks a button and
    Joe_Blow.aspx is created.

    I can create the file, no problem, by copying a template file and renaming
    it. But I need to be able to change the Title, description and keywords
    html tags for that new page automatically.

    Is that even possible?

    Thanks,

    Ross
     
    Ross Culver, Aug 27, 2007
    #1
    1. Advertising

  2. "Ross Culver" <> wrote in message
    news:...

    >I need to be able to create a new aspx file for new users that are specific
    >and optimized for that user. For instance, Joe Blow clicks a button and
    >Joe_Blow.aspx is created.
    >
    > I can create the file, no problem, by copying a template file and renaming
    > it. But I need to be able to change the Title, description and keywords
    > html tags for that new page automatically.
    >
    > Is that even possible?


    Several solutions...

    I'd probably just use the System.IO namespace to open the newly created
    file, read its contents, do a find and replace as necessary and then save
    the file...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Aug 27, 2007
    #2
    1. Advertising

  3. Ross Culver

    Ross Culver Guest

    Thanks, Mark. This is new to me, but I'll try it out and see how it works.

    Thanks, again for the quick response.

    Ross


    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Ross Culver" <> wrote in message
    > news:...
    >
    >>I need to be able to create a new aspx file for new users that are
    >>specific and optimized for that user. For instance, Joe Blow clicks a
    >>button and Joe_Blow.aspx is created.
    >>
    >> I can create the file, no problem, by copying a template file and
    >> renaming it. But I need to be able to change the Title, description and
    >> keywords html tags for that new page automatically.
    >>
    >> Is that even possible?

    >
    > Several solutions...
    >
    > I'd probably just use the System.IO namespace to open the newly created
    > file, read its contents, do a find and replace as necessary and then save
    > the file...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Ross Culver, Aug 27, 2007
    #3
  4. On Aug 27, 5:16 pm, "Ross Culver" <> wrote:
    > Thanks, Mark. This is new to me, but I'll try it out and see how it works.
    >
    > Thanks, again for the quick response.
    >
    > Ross
    >
    > "Mark Rae [MVP]" <> wrote in messagenews:...
    >
    >
    >
    > > "Ross Culver" <> wrote in message
    > >news:...

    >
    > >>I need to be able to create a new aspx file for new users that are
    > >>specific and optimized for that user. For instance, Joe Blow clicks a
    > >>button and Joe_Blow.aspx is created.

    >
    > >> I can create the file, no problem, by copying a template file and
    > >> renaming it. But I need to be able to change the Title, description and
    > >> keywords html tags for that new page automatically.

    >
    > >> Is that even possible?

    >
    > > Several solutions...

    >
    > > I'd probably just use the System.IO namespace to open the newly created
    > > file, read its contents, do a find and replace as necessary and then save
    > > the file...

    >
    > > --
    > > Mark Rae
    > > ASP.NET MVP
    > >http://www.markrae.net- Hide quoted text -

    >
    > - Show quoted text -


    You can also consider having "url rewriting"
    http://www.google.com/search?hl=en&q=url rewriting asp.net

    This allows you to have a single page (say, a template), make a
    request for Joe_Blow.aspx when it does not exist and the process that
    request as you need (with unique title, description, keywords and so
    on)
     
    Alexey Smirnov, Aug 27, 2007
    #4
  5. Ross Culver

    Ross Culver Guest

    Alexey,

    This looks very interesting; but I'm not sure if its going to accomplish
    what I'm after. If the pages do not already exist, then they won't get
    crawled by the webbots so they're unique titles, descriptions and keywords
    will be indexed by the search engines. Please, correct me if I'm wrong, but
    the rewrite url routine looks like a good way to redirect a user from a
    non-existent url to a dynamic one.

    Thanks again, though. I'm sure this will come in handy for other scenarios.

    Ross


    "Alexey Smirnov" <> wrote in message
    news:...
    > On Aug 27, 5:16 pm, "Ross Culver" <> wrote:
    >> Thanks, Mark. This is new to me, but I'll try it out and see how it
    >> works.
    >>
    >> Thanks, again for the quick response.
    >>
    >> Ross
    >>
    >> "Mark Rae [MVP]" <> wrote in
    >> messagenews:...
    >>
    >>
    >>
    >> > "Ross Culver" <> wrote in message
    >> >news:...

    >>
    >> >>I need to be able to create a new aspx file for new users that are
    >> >>specific and optimized for that user. For instance, Joe Blow clicks a
    >> >>button and Joe_Blow.aspx is created.

    >>
    >> >> I can create the file, no problem, by copying a template file and
    >> >> renaming it. But I need to be able to change the Title, description
    >> >> and
    >> >> keywords html tags for that new page automatically.

    >>
    >> >> Is that even possible?

    >>
    >> > Several solutions...

    >>
    >> > I'd probably just use the System.IO namespace to open the newly created
    >> > file, read its contents, do a find and replace as necessary and then
    >> > save
    >> > the file...

    >>
    >> > --
    >> > Mark Rae
    >> > ASP.NET MVP
    >> >http://www.markrae.net- Hide quoted text -

    >>
    >> - Show quoted text -

    >
    > You can also consider having "url rewriting"
    > http://www.google.com/search?hl=en&q=url rewriting asp.net
    >
    > This allows you to have a single page (say, a template), make a
    > request for Joe_Blow.aspx when it does not exist and the process that
    > request as you need (with unique title, description, keywords and so
    > on)
    >
     
    Ross Culver, Aug 27, 2007
    #5
  6. On Aug 27, 11:55 pm, "Ross Culver" <> wrote:
    > Alexey,
    >
    > This looks very interesting; but I'm not sure if its going to accomplish
    > what I'm after. If the pages do not already exist, then they won't get
    > crawled by the webbots so they're unique titles, descriptions and keywords
    > will be indexed by the search engines. Please, correct me if I'm wrong, but
    > the rewrite url routine looks like a good way to redirect a user from a
    > non-existent url to a dynamic one.
    >
    > Thanks again, though. I'm sure this will come in handy for other scenarios.
    >
    > Ross
    >


    The bot doesn't know that the page doesn't really exist, because the
    response code will be 200 and not 404 (doesn't exist) or 301
    (redirect). It will crawl all such links.

    Look at this page
    http://www.google.com/search?hl=en&q=url rewriting asp.net

    There are few links similar to

    www.aspnetworld.com/articles/2004011901.aspx
    msdn2.microsoft.com/en-us/library/ms972974.aspx
    weblogs.asp.net/jezell/archive/2004/03/15/90045.aspx

    This is how the url rewriting works
     
    Alexey Smirnov, Aug 27, 2007
    #6
  7. Ross Culver

    Ross Culver Guest

    Alexey,

    Ok, this would work if the querystring parameter I was passing to the aspx
    page was descriptive, for instance,
    http://www.domain.com/basicpage.aspx?doctor=doctorname.
    But I'm passing an integer value, the doctor's id number, like
    http://www.domain.com/basicpage.aspx?docid=15248, which has no optimization
    value (no one is search for '15248', they're searching for 'Dr. Bill'. I
    can't really use the doctor's name as the parameter because of the
    possibility of several doctors with the same name. If I'm missing
    something, please let me know.

    Thanks, again.

    Ross

    "Alexey Smirnov" <> wrote in message
    news:...
    > On Aug 27, 11:55 pm, "Ross Culver" <> wrote:
    >> Alexey,
    >>
    >> This looks very interesting; but I'm not sure if its going to accomplish
    >> what I'm after. If the pages do not already exist, then they won't get
    >> crawled by the webbots so they're unique titles, descriptions and
    >> keywords
    >> will be indexed by the search engines. Please, correct me if I'm wrong,
    >> but
    >> the rewrite url routine looks like a good way to redirect a user from a
    >> non-existent url to a dynamic one.
    >>
    >> Thanks again, though. I'm sure this will come in handy for other
    >> scenarios.
    >>
    >> Ross
    >>

    >
    > The bot doesn't know that the page doesn't really exist, because the
    > response code will be 200 and not 404 (doesn't exist) or 301
    > (redirect). It will crawl all such links.
    >
    > Look at this page
    > http://www.google.com/search?hl=en&q=url rewriting asp.net
    >
    > There are few links similar to
    >
    > www.aspnetworld.com/articles/2004011901.aspx
    > msdn2.microsoft.com/en-us/library/ms972974.aspx
    > weblogs.asp.net/jezell/archive/2004/03/15/90045.aspx
    >
    > This is how the url rewriting works
    >
     
    Ross Culver, Aug 28, 2007
    #7
  8. Ross Culver

    Ross Culver Guest

    Mark,

    I was able to create the file and even write back to the html using the
    streamwriter and the replace() function. I placed the write procedure
    within an if statement that checked for the existence of the original phrase
    and even though the procedure ran without error, it didn't replace the
    string. Then I looked further down on the page, several lines down in the
    body, and saw that it wrote my replacement string down there where the
    original phrase was not.

    I'm so close, but do you know why it wrote where it did? Below is a snippet
    of the code. Note that I'm really only checking the first line of the page.
    Dim FS As FileStream, LineText As String = Nothing
    FS = New FileStream(FileName, FileMode.Open,
    FileAccess.ReadWrite, FileShare.ReadWrite)

    Dim SR As New StreamReader(FS) ', SW As New StreamWriter(FS)

    Dim itm As String = SR.ReadLine

    While Not itm = Nothing

    If Microsoft.VisualBasic.InStr(itm, "Full_Listing") > 0 Then

    Dim SW As New StreamWriter(FS)

    SW.WriteLine(Microsoft.VisualBasic.Replace(itm,
    "Full_Listing", "Natarajan_Asokan"))

    SW.Close()

    Me.labMsg.Text = "Updated!"

    Else

    Me.labMsg.Text = "Didn't find it"

    End If

    X = X + 1

    If X = 1 Then Exit While

    End While

    SR.Close()

    FS.Close()

    Thanks, again, for the assistance.

    Ross


    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Ross Culver" <> wrote in message
    > news:...
    >
    >>I need to be able to create a new aspx file for new users that are
    >>specific and optimized for that user. For instance, Joe Blow clicks a
    >>button and Joe_Blow.aspx is created.
    >>
    >> I can create the file, no problem, by copying a template file and
    >> renaming it. But I need to be able to change the Title, description and
    >> keywords html tags for that new page automatically.
    >>
    >> Is that even possible?

    >
    > Several solutions...
    >
    > I'd probably just use the System.IO namespace to open the newly created
    > file, read its contents, do a find and replace as necessary and then save
    > the file...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Ross Culver, Aug 28, 2007
    #8
  9. "Ross Culver" <> wrote in message
    news:...

    > Thanks, again, for the assistance.


    That's not actually what I suggested... ;-)

    1) Open the "template" file

    2) Read its entire contents into a string variable

    3) Close the template file

    4) Do the find and replace as necessary on the string variable

    5) Create a new file and write the entire contents of the string variable
    into it

    6) Save the new file


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Aug 28, 2007
    #9
  10. On Aug 28, 4:06 pm, "Ross Culver" <> wrote:
    > Alexey,
    >
    > Ok, this would work if the querystring parameter I was passing to the aspx
    > page was descriptive, for instance,http://www.domain.com/basicpage.aspx?doctor=doctorname.
    > But I'm passing an integer value, the doctor's id number, likehttp://www.domain.com/basicpage.aspx?docid=15248, which has no optimization
    > value (no one is search for '15248', they're searching for 'Dr. Bill'. I
    > can't really use the doctor's name as the parameter because of the
    > possibility of several doctors with the same name. If I'm missing
    > something, please let me know.
    >


    When you wanted to save Joe_Blow.aspx as a file how to do you deal
    with the case when there are two doctors with the same name? If I were
    you I would rewrite this as .../Doctors/15248/Joe_Blow.aspx with the
    id and the name in the url or simply ../Doctors/15248.aspx. The id
    will be used to call a database, the name is just for a webbot (even
    it has not very big meaning for SEO)
     
    Alexey Smirnov, Aug 28, 2007
    #10
  11. Ross Culver

    Ross Culver Guest

    That's exactly what I did and it worked great! I was able to create over
    100,000 aspx pages with individual unique title, description and keyword
    meta tags in less than 30 minutes! And since the actual data, images and
    maps on each are dynamic and based off an ID which I updated in the string
    variable before creating the new file, every single page is uniquely
    different and specific!

    Thanks a million, Mark.


    "Mark Rae [MVP]" <> wrote in message
    news:eUKi8$...
    > "Ross Culver" <> wrote in message
    > news:...
    >
    >> Thanks, again, for the assistance.

    >
    > That's not actually what I suggested... ;-)
    >
    > 1) Open the "template" file
    >
    > 2) Read its entire contents into a string variable
    >
    > 3) Close the template file
    >
    > 4) Do the find and replace as necessary on the string variable
    >
    > 5) Create a new file and write the entire contents of the string variable
    > into it
    >
    > 6) Save the new file
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Ross Culver, Aug 29, 2007
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ntm
    Replies:
    2
    Views:
    4,701
    Teemu Keiski
    Jan 19, 2004
  2. LM
    Replies:
    1
    Views:
    7,150
    =?Utf-8?B?RFdT?=
    Mar 1, 2006
  3. shruds
    Replies:
    1
    Views:
    845
    John C. Bollinger
    Jan 27, 2006
  4. Nym Pseudo

    META NAME and META HTTP-EQUIV

    Nym Pseudo, Sep 26, 2003, in forum: HTML
    Replies:
    1
    Views:
    564
    =?iso-8859-1?Q?brucie?=
    Sep 26, 2003
  5. Tamara
    Replies:
    2
    Views:
    127
    Michele Dondi
    Apr 7, 2004
Loading...

Share This Page