Today I have a requirement for my company website (in ASP.NET MVC 3).
One of the static pages - a PDF file (from the "Content" folder) from the website of my companies is displayed in Google search results. My company wants the pdf file to be available only for login.
To do this, I created a route and decorated it with RouteExistingFiles = true;
routes.RouteExistingFiles = true;
routes.MapRoute(
"RouteForContentFolder",
"Content/PDF/ABC.pdf",
new { controller = "User", action = "OpenContentResources", id = UrlParameter.Optional }
);
In UserController, I wrote an OpenContentResources action method that redirects the user to a URL
[CompanyAuthorize(AppFunction.AccessToPDFFiles)]
public ActionResult OpenContentResources()
{
return Redirect("http://localhost:9000/Content/PDF/ABC.pdf");
}
But this code runs in an infinite loop and never runs. Can anyone help me with my care.
Thank...
source
share