I’ve had windows 8 at home for a while and have been really frustrated with it. This video is a face-palm moment - “Why didn’t I google for this before”. See here
Allowing IIS 7.5 Applications to communicate with SQL server via Windows Authentication
2013/05/11Here’s a quick way of getting your ASP.NET application to talk to your SQL Server database once you’ve made the move to use IIS instead of IISExpress. This topic is meant to serve as a quick guide for developers (to get them up and running), and not as a comprehensive security guide. Names have been blanked out to protect the innocent.1. If you have created a specific Application Pool for your ASP.NET application, then skip to step 4. Otherwise, it’s time to do so.
2. Configure the application pool – select the version of the .Net framework you desire.
3. Edit your IIS Application to use this application pool
4. In SQL Server Enterprise Manager, create a new Login
5. Enter the details for the login manually (do not use search) as IIS APPPOOL\MyApplicationPool
6. In the user mapping, configure this login to have access to your database
7. When you press OK, you should now have a login under both the general Security/Logins folder and within the mydatabase->Users folder as below.
Job done… hopefully.
As I said, this is intended as a quick guide rather than a comprehensive security-based tutorial. If I find articles that improve this post, I’ll add them later.
This post is a reblog of the content I discovered here http://stackoverflow.com/questions/1933134/add-iis-7-apppool-identities-as-sql-server-logons
Installing IIS On Windows Server 2008 R2
2013/05/11After installing Windows Server 2008 R2, you may be scratching your head trying to work out where Internet Information Services (IIS) is. Well, it’s not installed by default, so the natural thing would be to go to the traditional ‘add/remove windows features” dialog. However, things have changed in Windows Server 2008 R2! – You start the process by adding a role to the server.
See this link for more information.
Windows Server 2008 “Your current security settings do not allow this file to be downloaded”
2013/05/08Occasionally I have to install a Web server or SQL Server on a fresh Windows Server 2008 R2 operating system, and by far the most annoying bit about it is just getting windows updates and the downloads you need onto the machine. Here’s a reminder (more for myself) how to quickly enable Internet Explorer 9 to act normally, even if it’s just temporarily.
There are a few options to get the job done.
Option 1 Add the site to your trusted sites
When you try and click a link, you’ll probably see this dialog.
You can simply add the current site to the trusted sites list by the Add… button.
This has the same effect as enabling file downloads manually (Option 2) but will also allow much more than just file downloads to take place, so only use this if you really do trust the site.
Option 2 Enable file downloads for the internet zone
- Open Internet Explorer.
- Click the Cog icon and then click on Internet Options
- Click on the Security tab
- Select the Internet Zone.
- Click on the Custom Level… button
- Scroll to the Download section.
- Enable File download.
- Click OK and .
- Restart Internet Explorer.
Option 3 Use another computer to get the downloads (recommended for maximum security)
- Use whatever mechanism you can to transfer the files (USB, File share, FTP, DVD, ISO mount, the list goes on….)
Option 4 Install Google Chrome
- Yep, them pesky settings only apply to IE!
Option 5 Disable Protection (probably the worst idea and might not help at all)
Because there are many ways in which you can have a file sent to you (not just by clicking a direct link) you may find that the only way to get the download started (other than trusting the site), is to disable protection. I’ve not encountered a situation yet where this has helped, but I’ve not tried hard enough. I’ve seen this suggested on other forums so thought I’d better include it. But see the link at point 3, this option opens up a whole can of worms. If in doubt, choose option 3!
- Click the Cog icon, and select Internet Options
- Go to the Security tab
- Uncheck the Enable protected mode tick box. Want to know what it really does? See here.
- OK the Internet Options page and Restart IE
You will now be nagged about not being protected any more. Try not to catch a cold. If you love screen shots, see this guide.
What does .mdf file contain in an asp.net project?
2013/05/06(For Visual Studio 2012, ASP.NET 4) The .MDF file in an ASP.NET project is quite simply a SQL Server 2012 database file which supports the MVC application. The Model classes define the structure of the database using the Code First methodology. By default, in Visual Studio 2012 when you create an MVC application it will use the LocalDB engine to access the database, in earlier versions of Visual Studio the SQL Server Express engine was used. Once generated you can view the structure of the database within visual studio, or attach the .mdf file to a SQL Server instance and view it with SQL Server Management Studio.
See the official asp.net site for some fantastic tutorials and videos.
Error message: System.Data.Entity.EdmEntityType: EntityType ‘blah’ has no key defined. Define the key for this EntityType
2013/05/05If you’re trying to code an MVC app, you may see the following message appear when adding a controller class. There are a number of fixes for this on stack exchange and the internet, but yet again, I am special. I found another way in which you can get this error message.
Here’s my very simple model and context code which caused the error.
1: namespace TestMVC.Models
2: {
3: public class ItemContext : DbContext
4: {
5: public ItemContext()
6: : base("DefaultConnection")
7: {
8: }
9:
10: public DbSet<Item> Items { get; set; }
11: }
12:
13: public class Item
14: {
15: public int ItemId;
16: public string ItemName;
17: }
18: }
According to the multitude of stack-overflow answers like this one, all one needs to do is add the [Key] attribute before your ID member, and remember to include the System.ComponentModel.DataAnnotations namespace.
However, the conventions for code first development are at odds with my code, I shouldn’t need the [Key] attribute.
The actual answer to my particular problem, was that Visual Studio requires getters and setters on my ItemId. That simple. Here’s the fixed model class.
1: public class Item
2: {
3: public int ItemId {get;set;}
4: public string ItemName {get;set;}
5: }
Please let me know if this helped you, or if I’m missing something!
Allowing remote access to your IIS Express service
2013/04/21While developing an ASP.NET application with the IISExpress service, you might like to see how it looks on your mobile device connected to your LAN via Wi-Fi, or just any computer connected to your network.
If you do not happen to have the full IIS installed already, you can allow your IISExpress service to serve remote pages quickly and easily by following these steps.
Warning: By following these instructions you are solely liable for any security breach or problems you may face. Do not use this information if you do not agree with that statement.
Assume your machine name is ‘jedi’, and your port number is ’16253′, replace appropriately.
1. Run a command prompt as administrator, and type in
netsh http add urlacl url=http://jedi:16253/ user=everyone
2. Open up the following file in Notepad or Visual Studio
MyDocuments\IISExpress\config\ applicationhost.config
change the binding from:
<binding protocol="http" bindingInformation="*:16253:localhost" />
to:
<binding protocol="http" bindingInformation="*:16253:jedi" />
3. Restart the IISExpress service (use the tray icon or task manager).
4. In Visual Studio, change your Project->Properties->Web settings to launch http://jedi:16253 insead of http://localhost:16253
5. In a web browser on your development machine type http://jedi:16253/
6. Assuming all is good – Open up the port on the firewall.
- Goto the Windows Firewall with Advanced Security panel
- Create a new inbound rule
- Click ‘Port’
- Click ‘Next’
- Click TCP
- Enter a specific port 16253
- Click ‘Next’
- Click ‘Allow the connection’
- Click ‘Next’
- Click ‘Next’ (you could untick Public)
- Give it a name “My MVC App” and press Finish.
7. You should now be able to access the page on the mobile device when connected to the Wi-Fi using http://jedi:16253/
For more advanced information see Scott Hansleman’s blog post.
Posted by gilesey 












