RSS

Monthly Archives: January 2011

Configuring IIS 5.1 to run an MVC application

When hosting a MVC application under IIS 5.1 there are a couple of small changes to make in order for your application to run.  Basically IIS 5.1 doesn’t know what to do with the extensionless URLs that are so common with MVC routing so we have to tell IIS that if one is encountered then to throw it at the Framework 4 aspnet_isapi.dll

To accomplish this first ensure that you have installed .NET Framework verison 4 

Next, invoke the IIS Manager under Administrative Tools and Right Click on the Virtual directory for your application and hit Properties.

Properties Window

 

On this screen Click the Configuration Button and you will be presented with the following popup window

Add/Edit Application Extension Mappings Window

 

The Executable should point to the aspnet_isapi.dll for .NET Framework 4.  This is normally found in C:\Windows\Microsoft.NET\Framework\v4.0.30319

Set the Extension to be .* and uncheck the ‘Check that file exists’ checkbox

If the Ok button is still disabled clikc in the Executable text box and the OK button should enable itself.  Little Microsoft Bug me thinks!!

Right Save your settings are restart IIS.

Your MVC Application should now run under IIS 5.1

 
2 Comments

Posted by on January 12, 2011 in Entity Framework, IIS, MVC

 

Calling a User-Defined Function from the Entity Framework

Recently I have been working heavily in SQL server writing SPROCS but using a few User defined functions just to make things easier.  Well this morning I was back knee deep in .NET code and thought wouldn’t it be nice if I could use the Entity Framework to call out to my helper UDFs.

Well the answer is that its possible, infact its actually very simple, the only problem I found was that there were not many easy to understand articles on how to accompish this on the net.

So here is a quick Post on how to call User Defined Functions and return a Scalar Value from the Entity Framework.

Firstly we need to add the function to the Model Store.  Do to this open the Model Browser Window, Right-Click the Stored Procedures Folder and Select ‘Update Model from Database’

Add a User Defined Function to the Store

 

Once the function has been added, you can only call the function via SQL directly so in your code write some thing similar to this:

Calling the UDF from code

And thats all there is to it.  Told you it was easy!!