Using Cassini with a virtual path that contains dots
Asked Answered
H

1

1

I am working on an existing project in ASP.NET witch is based in a folder that contains dots

http://localhost/My.Awesome.WebClient/

This setup works fine using the integrated Visual Studio Develompent Server, but fails when I add MVC content and try to access it (Error 404 Resource not found).

http://msdn.microsoft.com/en-us/library/ee941656.aspx seems to explain the issue:

If you create a file system Web site in Visual Studio 2010 and the Web site is in a folder that contains a dot (.) in the folder name, URL routing will not work reliably. An HTTP 404 error is returned from some virtual paths. This occurs because Visual Studio 2010 launches the Visual Studio Development Server (Cassini) using an incorrect path for the root virtual directory.

However, the project is a Web Project, not a Web Site, and it only failed when I started using MVC.

The problem can be easily reproduced:

  1. File - New - Project - ASP.NET MVC 3 Web Application
  2. Edit project settings, Web: Use Visual Studio Development Server
  3. Set the virtual path to something that contains a dot
  4. Try to run the site

Is there a way to get this to work, besides using IIS instead of Cassini?

Edit:

I did find a workaround just now. It does not really work in a deployment scenario, but it may help in finding a solution:

in my Global.asax.cs file:

        routes.MapRoute(
            "Default", // Route name
            // Notice that I added the virtual path here
            "My.Awesome.WebClient/{controller}/{action}/{id}", // URL with parameters
            new { action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

        // This is also new
        routes.MapRoute(
            "Root", // Route name
            "", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

Using this workaround, my MVC-Sites work, but only with the following url:

http://localhost/My.Awesome.WebClient/My.Awesome.WebClient/
Hydropathy answered 22/2, 2012 at 9:39 Comment(0)
M
3

If you don't get an answer to this question (personally, I'm not aware of any way around this), I would recommend using "IIS Express", which is available as a free download. It can be installed on development machines and you can control a lot of server settings with your web.config file, which is fairly unobtrusive.

You can download it here:

http://www.microsoft.com/download/en/details.aspx?id=1038

I use IIS Express exclusively now; Cassini has always lacked features and IIS Express avoids me having to configure IIS for each web application.

Module answered 22/2, 2012 at 9:51 Comment(6)
In Visual Studio vNext, I think Cassini should be removed so as to force everyone to use IIS Express (though I personally suggest everyone uses local IIS 7 if possible as IIS Express is still not IIS).Melancholic
I disagree - Cassini has it's place. It's lightweight, comes pre-installed and doesn't listen on remote ports. See Scott Gu's blog for more comparisons: weblogs.asp.net/scottgu/archive/2010/06/28/…Module
I never heard of "IIS Express" until now, it really seems to offer all the functionalities that a developer needs. I will give it a try if there is no solution to this problem, thanks. I also like that it does not need administrative privileges to debug.Hydropathy
Aye, it sounded like you were referring to standard workstation IIS. IIS Express also allows you to set up advanced hosting options like windows authentication and SSL. You can also start it via the command line, which is handy for multiple hosting instances, such as when you're developing SOA.Module
Since VS 2012, IIS Express is built in. That solves all my problems.Hydropathy
Once IISExpress is installed VS 2010 also acts like it's built in - the configuration options are very similar to VS 2012 and 2013.Module

© 2022 - 2024 — McMap. All rights reserved.