I have a .Net Web Project, however for the most part we are using html pages (ideally we would have a website project instead). These pages are loading there dependencies with RequireJS, so the only Razer part is happening with loading the initial html page. Now, this site as both a home page and an admin page. The home page does not need to be secured on the same level as the admin page. Thus, we are using a mapPageRoute
for the home page to simply point to the appropriate home html page.
Now for the admin page, we need to have authentication and ensure that the user is an administrator. Currently, to achieve this, we have an AdminController
which returns a view (we added a custom location for this view, since it is not in the default Views folder). So our controller looks like this:
namespace XXXXX.YYY.Web.Controllers
{
public class AdminController : Controller
{
[RequiresPrivilegeAttribute(Constants.Security.Privileges.ADMINISTER_APPLICATION)]
public ActionResult Index()
{
return View();
}
}
}
What I would like to do is follow the same pattern I was for the home site, by defining a route to simply load an html file. For the home page, we are using this in the RouteConfig
(which happens on App_Start
):
routes.MapPageRoute(
"",
String.Empty,
"~/ui/dist/index.html"
);
For the Admin site route, our first and second parameter would be "Admin", and the third parameter would be the location of the admin index.html ("~/ui/dist/admin/index.html").
This won't work for the admin site, because it does not take into account administrator security. So the question is:
How can protect a path to an html file without having to use a controller?
Additionally, we are wanting to ultimately move away from a .NET MVC application and replace it with a pure HTML SPA. So I want to accomplish this without the use of a controller.