After trying to work this out for ages, thinking about routing conflict and more - I started a separate project from the start.
It looks like an MVC controller called "properties" always returns a 403.14 forbidden message when you try to access the root site (http://site/properties
) - however, other pages work (http://site/properties/index
).
It works fine as a controller in an area, but, I just can't create it in the main site.
I was wondering if anyone knows why and what the best way round this is?
MVC Properties are the following: Loose Coupling. Light weight code. Effective looks. More Security.
A controller is responsible for controlling the way that a user interacts with an MVC application. A controller contains the flow control logic for an ASP.NET MVC application. A controller determines what response to send back to a user when a user makes a browser request.
This is because of conventions. The default convention is /{controller}/{action} , where the action is optional and defaults to Index . So when you request /Scott , MVC's routing will go and look for a controller named ScottController , all because of conventions.
In addtion to DavidG's answer.
When you publish the project the compiled build does not have a Properties folder. To solve the issue while developing locally you can set RouteExistingFiles
to true
so ASP.NET routing handles all requests.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.RouteExistingFiles = true;
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
The issue is that your project already contains a folder called Properties
which is mainly used for the AssemblyInfo.cs
file but has other stuff in there too. The engine used to resolve what files to send to the client prioritises files and folders over routing. so the URL http://site/properties
is trying to server content from there, which is ultimately blocked anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With