Problem with getting file from VPP

Vote:
 

I have the VPP:

 

I have the folder with this adress: MySite\appdata\RobotsTxt, and 2 files in it:
robots.txt & sitemap.xml

If I don't mistake, when  i go to link like: http://localhost/MySite/Robots.txt, I should see a dialog offering to download my file. But I have no this.

What this may be because?

#120811
Apr 24, 2015 15:19
Vote:
 

Sorry to ask but why would you do like that?

These files should be in the root of the site, that is the place all robots are looking for them.

#120821
Apr 24, 2015 15:31
Vote:
 

To Henrik Fransas 

Yeah, I know. It could be any other file and robots was placed here just for test, and of course this file placed at root. But it's doesn't matter now. 

#120822
Apr 24, 2015 15:37
Vote:
 

Hello Aliaksei, you may want to consider using EPiRobots to render your robots.txt file as this means its editable inside EPiServer:

http://www.markeverard.com/2013/11/01/a-robots-txt-handler-for-episerver-7/

#120823
Apr 24, 2015 15:46
Vote:
 

To David Knipe 

I read this. But I user Episerver 8 and this module has a compatibility problems. I have no resolve for this.

#120827
Apr 24, 2015 16:32
Vote:
 

If you are using EPiServer 8, the VPP folders are pretty much gone.

#120830
Apr 24, 2015 16:38
Vote:
 

To Henrik Fransas

So how can i write file to server filesystem & after have posibility to load it? 

#120831
Apr 24, 2015 16:46
Vote:
 

If you are using MVC you can use routing. It might be possible with webforms also

Read more here:

http://stackoverflow.com/questions/21934150/static-file-routes-in-asp-net-mvc

#120832
Apr 24, 2015 16:51
Vote:
 

This link might be useful. It gives you good examples on how to write/read files 

http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Content/Assets-and-media/Working-with-media/

#120835
Apr 24, 2015 17:36
Vote:
 

Why not server the robots.txt as an ordinary property on startpage via an controller? Easy to create that if you like. Just an action returning a robots.txt instead of a view. You also need to register a route for the robots.txt in a initialization module of episerver.

But it is like 10 lines of code :) In the below sample I have used a settingspage but you could have the property stored in the startpage instead.

Something like this: http://www.edandersen.com/2013/02/17/adding-a-dynamic-robots-txt-file-to-an-asp-net-mvc-site/

 //Maps route for robots.txt
            RouteTable.Routes.MapRoute("RobotsTxtRoute", "robots.txt", new { controller = "RobotsTxt", action = "Index" });



 /// <summary>
    ///     Controller for serving robots.txt and content from startpage property.
    /// </summary>
    public class RobotsTxtController : Controller
    {
        private Injected<IContentLoader> ContentLoader { get; set; }

        [ContentOutputCache]
        public ActionResult Index()
        {
            var page = ContentLoader.Service.Get<StartPage>(ContentReference.StartPage);

            var settingsPage = ContentLoader.Service.Get<SettingsPage>(page.SettingsPage);
            string content = settingsPage.RobotsTxtContent;
            return Content(content, "text/plain");
        }
    }
#120841
Apr 25, 2015 22:03
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.