I've created an empty webapi project and I would like to add a homepage View. For some reason, it does not work - it always returns authorization access deny, but I've set the attribute [AllowAnonymous]
on HomeController
.
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
[AllowAnonymous]
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index()
{
return View();
}
}
Can anyone help with this issue please? Thanks