We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

Add/remove rules to robots.txt programmaticallyRSS

3 replies

Last post Oct 02, 2012 10:05 AM by Jagermeister

  • Add/remove rules to robots.txt programmatically

    Sep 11, 2012 08:10 AM|Jagermeister|LINK

    Hello,

    I would like to know if it is possible to add or remove rules to robots.txt programmatically, from ASP.NET.  Is there any API to do this? I don't need anything related to site analysis or sitemaps, just simple allow/disallow rules to robots.txt.

    I can see that going to IIS, clicking on 'SEO' and adding a new rule to exclude one site is quite easy, but I need a way to do that programmatically. And I would like to avoid accessing the file 'robots.txt' and parsing it myself.

    Thanks!

    robots.txt

  • Re: Add/remove rules to robots.txt programmatically

    Sep 11, 2012 08:15 AM|fab777|LINK

    Hi,

    have a look at the StreamWriter class: [url=http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx]http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx[/url]

     

    This message is provided "AS IS" with no warranties... But you can still mark it as answer if it's helped you.
    Fabrice ZERROUKI
    Wanna chill out? Here: JAHSound.net
  • Re: Add/remove rules to robots.txt programmatically

    Sep 14, 2012 03:59 AM|fab777|LINK

     Hi, did it fits your need?

    This message is provided "AS IS" with no warranties... But you can still mark it as answer if it's helped you.
    Fabrice ZERROUKI
    Wanna chill out? Here: JAHSound.net
  • Re: Add/remove rules to robots.txt programmatically

    Oct 02, 2012 10:05 AM|Jagermeister|LINK

    Hi,

    Thank you for your reply. Sorry for the late reply, I had "email subscription enabled" but the notification e-mail went to the spam folder, so I had thought no one replied :/

    StreamWriter class would mean editing the file directly, which is precisely what I would like to avoid.

    If there is an action that can be performed using a User Interface, I had assumed there would be some API to perform it programmatically, but according to all manuals and internet forums I'm starting to think that there is none.