0

So we've got a project that our tutorial software exports as an HTML project. (Root has an index.html file, folders for js, css, etc)

Our support portal with Identity account management runs on ASP.NET MVC.

What I'd like is for the HTML project to be accessible, but you must login first.

I've gone about it two ways, unsuccessful both times:

  • I can put the HTML project in a static folder in the root of the ASP project. This way I can access it as domain.com/Test/Course/index.html. Everything works fine here, js and css are loaded properly, but it is not password protected.

  • I can put it in the App_Data folder, create a route to an action with the [Authorize] parameter that returns a FileResult, grabbing from the App_Data folder. This locks, and on login loads the index.html file, but all of the html files resources (accompanying js and css files) fail to load because the paths are wrong. It's pulling from App_Data, but index.html is now somewhere else, away from it's included js and css folders.

Any ideas would be greatly appreciated.

adam3039
  • 1,171
  • 14
  • 27

1 Answers1

1

You'll want to take a look at these two questions:

How to do Forms Authentication on purely HTML pages using ASP.NET?

https://serverfault.com/questions/509879/protecting-static-content-with-forms-authentication-under-iis8

Basically - ASP.NET doesn't by default handle .html content because it's much faster to have IIS handle it directly. You need to configure it correctly to have it apply to .html files so that it can then apply its authentication model.

Community
  • 1
  • 1
John Christensen
  • 5,020
  • 1
  • 28
  • 26
  • Cheers, putting the new web.config in the subfolder did the trick. Did not know I could do that. Thanks! – adam3039 Sep 09 '15 at 21:00