1

On my web site I previously had a page located at "/careers". I recently decided to rename this page to "/jobs". Now when I try to access this page on my published Azure Web Site I just get a 403 response with the following error:

You do not have permission to view this directory or page.

It works on my local dev machine, and it works if I rename the action to "jobs". Why am I not allowed to create a route called "jobs"? Is this reserved in Azure for some bizarre reason?

// Does not work
public ActionResult Jobs()
{
    return View("jobs");
}

// Does work
public ActionResult Jobs2()
{
    return View("jobs");
}

From what I can tell, my routes should not be preventing me from using this action, and I don't have any sub-directories called "Jobs" in either my Views folder or my Controllers folder.

Edit:

I just noticed that the issue is not actually "/jobs", but rather "/jobs/". For some reason Chrome was redirecting me to "/jobs/" (probably due to history). I tried the same for other routes and it works fine.

/features (works)
/features/ (works)
/jobs (works)
/jobs/ (does not work)
pqvst
  • 4,344
  • 6
  • 33
  • 42
  • Check if you also have a "jobs" folder in your app root directory. MVC will not apply route if exact folder/file exist, unless you apply `routes.RouteExistingFiles=true`, which sometimes can be very troublesome. I would suggest to consider renaming the folder if this is the case. – tweray Apr 17 '14 at 13:09
  • I only have one Jobs folder, which is located inside a Downloads folder (i.e. it is not in the root directory). I also tried renaming this folder, but that did not help. – pqvst Apr 17 '14 at 13:15
  • Did some search and found [something interesting](http://blog.amitapple.com/post/74215124623/deploy-azure-webjobs/). So maybe you are right that the /jobs folder is reserved for webjobs. In this case I believe a work around is to do [URL Rewrite](http://stackoverflow.com/questions/14126842/mvc-routing-static-file). That you can rewrite when `/jobs` coming into `/jobs2` or something else. – tweray Apr 17 '14 at 13:35
  • I've tried adding an explicit route for "jobs", but that does not seem to work either :( `routes.MapRoute("Jobs", "jobs", new { controller = "Default", action = "Jobs" });` – pqvst Apr 17 '14 at 14:01
  • All route will be ignored if there is exactly a folder exist there, unless you apply `routes.RouteExistingFiles=true`. You can try to add this but it can be risky. Or a safer way is to do URL Rewrite either using the URL Rewrite module in web.config, or manually do that in code in global.asax. Let me know if you need some exact code as example. – tweray Apr 17 '14 at 14:16
  • A tried performing a RewritePath in my Global.asax, to my "/jobs2" action. This still doesnt work... I really don't understand what is going on here. I've posted on the MSDN forums as well, maybe someone there can shed some light on this... – pqvst Apr 17 '14 at 14:30
  • I have a simple MVC web app with a "Jobs" route here: https://github.com/amitapl/jobwithweb it works perfectly fine so the issue is probably with your routes, can you share your routes maybe? – Amit Apple Apr 17 '14 at 18:01
  • @AmitApple see my edit. Are you able to reproduce the issue if you navigate to "/jobs/" with a trailing backslash (note that it works fine on my local dev machine, but not when published to Azure). – pqvst Apr 17 '14 at 21:26
  • ```/jobs/``` also works for me, did you check whether your site on Azure has a jobs directory? (under d:\home\site\wwwroot\[jobs]), also try using http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx/ to debug your routes – Amit Apple Apr 17 '14 at 23:14
  • I haven't added a jobs directory myself. How would I go about checking the actual files that are on Azure? I didn't think this was possible with Azure Websites. – pqvst Apr 18 '14 at 22:00
  • @pbergqvist there are 2 ways you can check the folders for your azure site. You can use FTP with any ftp client (I usually use FileZilla) and you can get your FTP credentials from the publishing profile you can download from portal. Or you can go to the SCM endpoint for your site basically go here `https://.scm.azurewebsites.net` log in with the webdeploy credentials from the publishing profile, then click on the tab at the top called `Debug console` and you will see a File Explorer and Console view into your site – ahmelsayed Apr 20 '14 at 03:35

1 Answers1

0

By accessing my site on Azure with FTP I was now able to see that there in fact was a "jobs" folder uploaded on Azure (files left behind by an older version of the website).

pqvst
  • 4,344
  • 6
  • 33
  • 42