How to Get a Website Running on Full IIS, Including a SQL Server Express with Advanced Services Database

I am writing this guide mainly for myself, in case I ever need to reinstall Windows 8, so it may not match your needs exactly. I am working with W8 here (not W8.1) because my PC comes with an installation disc for W8. However, the upgrade to W8.1 is free for everyone, so I tried that as well, and I only had to go through steps 12 and 13 on Windows 8.1.

That does not mean, though, that someone else, or you at another time, won’t have to go through them on a version of Windows other than 8.1 too. I am also working with Visual Studio Express 2012 for Web here.

1) Install W8 and, after it starts, set up your account. The installer didn’t give me the option to sign in with a Microsoft Account, so I created a Local Account.

2) Go to the settings (I did it in the “Metro” settings) and switch your account to a Microsoft Account. You will need your email address and its password.

3) Copy all the installers you want to run onto the C: drive. The reason is that some installation processes store programs and libraries on the drive they were installed from, which can leave you with “unnecessary” folders or files there. To be safe, I also remove the drive letters of all drives other than C: so that nothing really gets written to them.

4) Run the SQL Server 2012 with Advanced Services installation. I chose to install all components, including LocalDB, which is not installed by default. On the Instance Configuration page I chose Default instance, because I have it written everywhere that my server is named MSSQLSERVER. On the Server Configuration page I set the startup type of SQL Server Reporting Services to Manual, because I don’t use them.

On the next page, Database Engine Configuration, I set Authentication Mode to Mixed Mode and entered my password for sa (System administrator) – this account is used only for SQL Server. On the neighboring tab, Data Directories, I set the User database directory path to C:\Documents\MSSQLSERVER, and this path is automatically applied to the User database log directory as well. This is the path where your SQL Server databases will be stored. I left everything else at the default values and started the installation. You can restart your PC, but I didn’t.

5) Install Visual Studio Express 2012 for Web. You can restart your PC; this time I did.

6) Install Visual Studio Update 4. Especially for 2012 for Web this is important so that tag closing works in the ASPX editor. After installation it asks for a restart, so let’s do it – Microsoft presumably knows it matters, otherwise they wouldn’t ask for it.

7) If something like this appeared after opening your project in VS12 for Web:



it means that you don’t have full IIS installed. And since we want our website to run on full IIS, we click No and the project won’t load. So if this window appeared, continue with step 8; otherwise skip straight to step 9.

8) In the Windows Features window, which you open from the Control Panel, I installed IIS by checking Internet Information Services->World Wide Web Services->Application Development Features->ASP.NET 4.5, and this component depends on a whole range of other components, which were checked automatically as well. Then I also checked World Wide Web Services->Common HTTP Features->Static Content so that images and *.html pages get served. Under Common HTTP Features it is also a good idea to check HTTP Errors, so that when something goes wrong you know why your website isn’t showing and you don’t just get a blank white page. It is also useful to check HTTP Redirection right next to it, because every ASP.NET developer will surely redirect a page using .NET at some point. Next, Application Development Features->Application Initialization, which appears to be important for Global.asax. And finally Internet Information Services->Web Management Tools->IIS Management Console, so you can configure this IIS through a GUI.

9) Open the IIS Management Console (typing “internet” or “iis” into the Windows search should be enough), change the path to your web project for the Default Web Site, and restart this website. Now restart your PC as well.

10) Now you can load your web project in VS. If it still refuses to load because of this error:



open VS as administrator.

11) Now you can try opening the page RIP – this server didn’t even survive its own hosting. in your web browser. Most likely, though, you will see an error like this: Cannot open database "sunamo.cz" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\DefaultAppPool'. You fix it by opening SQL Server Management Studio, signing in with Windows Authentication, selecting Security->Logins->New Login in the Object Explorer on the right, and pasting IIS APPPOOL\DefaultAppPool into Login name.

It is also important to assign all Server Roles in this dialog. Of course, you also have to attach your database (the *.mdf and *_log.ldf files) so that SQL Server has something to load data from. After this it is absolutely necessary to restart your PC (restarting just the SQL Server service is not enough) so that your browser stops showing the error: “Cannot open database “database” requested by the login. The login failed. Login failed for user ‘IIS APPPOOL\DefaultAppPool’.”

12) If you are not on Windows 8 but on one of the earlier versions of Windows, you also have to register IIS. The Turn Windows features on or off dialog only copies the files needed to run IIS, but does not perform the necessary registrations in the system.

So if you have 64-bit Windows, run cmd (Win+R, type cmd and press Enter – of course you have to be in an administrator account on the PC, otherwise the command prompt won’t start in admin mode) and enter the following command: %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i. For a 32-bit OS the command is as follows: %windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -i. If the aspnet_regiis.exe file is not found, change the version to your version of the .NET Framework.

13) This step and the next one should only be needed on Windows 8.1, but if you get error 500.19, follow these steps on another OS as well. If your website shows the error HTTP Error 500.19 - Internal Server Error, it means that IIS doesn’t have even the slightest permission to read anything from your website folder. So grant Full Control permissions (read and maybe execute should be enough, but I set Full Control just to be safe) to the IIS_IUSRS user, which is the account for ApplicationPoolIdentity.

14) If you still can’t get the website to show, this time with the error HTTP Error 401.3 - Unauthorized, it means that IIS is trying to browse your website under the account IUSR. So either repeat step 12, just with the IUSR account, or open your site in the IIS management console, click Authentication, then Anonymous Authentication, Edit, and change it from Specific user (probably IUSR) to Application pool identity:



I tried both options, one of which I then reverted

15) At this point the website should already be working, and we can move on to configuring this website in VS. So open your project settings and select the Web tab on the left. Check the settings so that they look like mine here:



I also clicked Create Virtual Directory here, but I think that is only for IIS Express. And now it works.

Unfortunately, now the Use Visual Studio Development Server or “Use Local IIS Web Server->Use IIS Express” option doesn’t work for me because of the error ” Could not load file or assembly sunamo.cz or one of its dependencies. An attempt was made to load a program with an incorrect format. “.

If you want to avoid this error, set Platform target to x86 in the project properties and enable 32-bit code in the DefaultAppPool – that is, the AppPool you use to serve ASP.NET pages. Now all 4 methods should work for you – Use Visual Studio Development Server, “Use Local IIS Web Server->Use IIS Express“, Use Local IIS Web Server, and simply opening the address RIP – this server didn’t even survive its own hosting. in the browser without Visual Studio.

Categories

Leave a Reply