Not IIS Express. Real IIS.
So, I’ve been playing around with two projects in order to jumpstart my learning of Asp.Net 5 MVC 6, TheWorld and Boilerplate, and had difficulty getting them to run under IIS (even after getting them to run fine with IIS Express). TheWorld would throw up a 500 server error with no information to be found, while the latter kept redirecting for no apparent reason. The solution to each was different, though some common troubleshooting helped.
The best thing you can do is make sure you have this line in your web.config:
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="true" startupTimeLimit="3600"/>
The key item is the stoutLogEnabled=”true” part, as this will put a log file that will alert you to errors you simply can’t see otherwise.
TheWorld: a simple app to highlight the basics of the Pluralsight course, it uses a LocalDB database (which it tries to seed on startup if there is no data available), Angular, Bootstrap, and EF7. Works perfectly in IIS Express. Publish to the file system, set it up in IIS, browse to home page…..500.0 error oops page. No other info. You can change settings in IIS to pass on more or less debugging info, etc., no use. Nothing in Event Viewer. Swell.
Finally, after figuring out the standard out logging thing….hmm:
Application startup exception: System.Exception: Could not resolve a service of type 'TheWorld.Models.WorldContextSeedData' for the parameter 'seeder' of method 'Configure' on type 'TheWorld.Startup'.
What the hell, it works in IIS Express……immediately, I thought to myself “LocalDB….export database to regular SQL Server, change config, bet that works.” Yep. That works. I’m sure there’s a way to get LocalDB to work with IIS, but, I’m good.
Boilerplate: a very highly configured, opinionated site (which is why I’m looking at it), once again, works great in IIS Express, publish to local file system, set up in IIS, browse to home page (which I set up on 8082)…..it redirects to the site on localhost. Hmm, to the SSL port on localhost. After a hell of a lot of WTF troubleshooting, I pay attention to the IIS logs. Hmm, what’s this:
2016-01-07 06:41:22 ::1 GET / - 8082 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/47.0.2526.106+Safari/537.36 - 307 0 0 3
What the hell is a 307 error? Redirect? I’m not redirecting, and it works in IIS Express. Google-fu says:
HSTS? What’s that? Hmm, what’s this line in startup.whatever.cs:
application.UseHsts(options => options.MaxAge(days: 18 * 7).IncludeSubdomains().Preload());
Johnny Dumbass Developer knows to comment that out…boom, there you go.
My major takeaway remains how unbelieveably unready for prime time this shit is. Johnny Dumbass Developer is still going to do a major site redesign using it, because he’s a dumbass, but it really is mind boggling how many basic items just don’t work or seem to have been unthought of. Publishing to IIS, something you would think is the baseline case, isn’t implemented at all, you have to do the publish to file system (which requires you to stop the site for it to work) thing, the vast difficulty in getting EF 6 to work (with EF 7 being a useless piece of shit at this point), no upgrade or migration paths for things like Web Api (just fuck along with Johnny Dumbass Developer, it will work!!!!! Oh, you need PATCH support? Sorry)….this is crazy stuff.
The Hanselman and Hunter comedy roadshow is great and all, but what the hell.