I am developping a web application by using the ASP .NET MVC 3 framework.
I am using Windows XP Professional on my computer.
I have decided to execute my web application via my IIS 5.1 local server during the development.
First I have installed IIS 5.1.
Then I have created a virtual directory under the default web site for my web application.
Then I have executed the following command line :
aspnet_regiis -i
Then I have added the following extension mapping to my virtual directory :
- Executable : C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
- Extension : .*
- Option “Check file existence” unchecked.
For information here is my RegisterRoutes method written in my Global.asax.cs file :
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Accueil", action = "Accueil", id = UrlParameter.Optional } // Default parameters
);
}
When I launch my web application via Visual Studio 2010 in debug mode then I can load one my view with success.
But I noticed that an image was not loaded.
Here is the img tag containing the image :
<img src="../../../Content/images/Valider_064.png" alt="Valider" />
Here is a piece of my web application folder tree :
- ActivitesHtml5 [FOLDER] : Root of web application
- Content [FOLDER]
- images [FOLDER]
- Valider_064.png [FILE]
- images [FOLDER]
- Controller [FOLDER]
- ConnexionController.cs [FILE] : Contains the action method to generate my view.
- Views [FOLDER]
- Connexion [FOLDER]
- Connexion [FOLDER]
- Connexion.cshtml [FILE] : Razor file of my view.
- Connexion [FOLDER]
- Connexion [FOLDER]
- Content [FOLDER]
Does someone know why my image is not correctly loaded ?
How about using url helpers instead of hardcoding your urls:
Also I would totally recommend you to stay away from IIS 5.1 especially if your target deployment server for the application will be IIS 7.0+. Cassini or IIS Express are much better alternatives and are directly integrated into Visual Studio.