today i came up with a requirement for my company website (build in ASP.NET MVC 3).
One of the static pages, a pdf file (from Content folder) from my companies website is shown up in Google searches. My company wants that pdf file to be accessible to only logged in users.
For that i created a Route and decorated it with RouteExistingFiles = true;
routes.RouteExistingFiles = true;
routes.MapRoute(
"RouteForContentFolder", // Route name
"Content/PDF/ABC.pdf", // URL with parameters
new { controller = "User", action = "OpenContentResources", id = UrlParameter.Optional } // Parameter defaults
);
In UserController I wrote an action method OpenContentResources which would redirect the user to the URL
[CompanyAuthorize(AppFunction.AccessToPDFFiles)]
public ActionResult OpenContentResources()
{
return Redirect("http://localhost:9000/Content/PDF/ABC.pdf");
}
But this code goes in infinite loop and never gets executed. Can any one help me around with my concern.
Thanks ...