使用卡西尼与包含点的虚拟路径 [英] Using Cassini with a virtual path that contains dots

查看:195
本文介绍了使用卡西尼与包含点的虚拟路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET女巫现有项目的工作基于包含点的文件夹中。

  HTTP://localhost/My.Awesome.WebClient/

此设置工作正常使用集成的Visual Studio的发展探析服务器,但是当我加入MVC的内容并尝试访问失败(错误404未找​​到资源)。

http://msdn.microsoft.com/en-us/library/ ee941656.aspx 似乎可以解释这个问题:


  

如果您在Visual Studio 2010中的文件系统网站,并在文件夹名称的网站是包含一个点一个文件夹中(。),URL路由将无法可靠地工作。从一些虚拟路径返回一个HTTP 404错误。这是因为Visual Studio 2010中使用不正确的路径为根虚拟目录启动Visual Studio开发服务器(卡西尼)。


不过,该项目是一个 Web项目,而不是一个网站,它只有当我开始使用MVC失败。

这个问题可以容易地再现:


  1. 文件 - 新建 - 项目 - ASP.NET MVC 3 Web应用程序

  2. 编辑项目设置,网站:使用Visual Studio开发服务器

  3. 的虚拟路径设置的东西,包含一个圆点

  4. 尝试运行网站

有没有办法得到这个工作,除了使用的,而不是卡西尼IIS?

编辑:

我没有刚才找到一个解决办法。它并没有真正在部署方案中工作,但它可能会找到解决办法帮助:

在我的Global.asax.cs文件:

  routes.MapRoute(
            默认,//路线名称
            //请注意,我这里添加的虚拟路径
            My.Awesome.WebClient / {控制器} / {行动} / {ID},// URL带参数
            新{行动=索引,ID = UrlParameter.Optional} //参数默认
        );        //这也是新
        routes.MapRoute(
            根,//路线名称
            ,//带参数的URL
            新{控制器=家,行动=索引,ID = UrlParameter.Optional} //参数默认
        );

使用此解决方案,我的MVC-站点的工作,但只能用以下网址:

  HTTP://localhost/My.Awesome.WebClient/My.Awesome.WebClient/


解决方案

如果你没有得到的答案,这个问题(就个人而言,我不知道解决这个办法),我会建议使用IIS前preSS,这是可以免费下载。它可以安装在开发机器,你可以控制大量的服务器设置与你的web.config文件,这是相当不显眼。

您可以在这里下载:

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

我用IIS防爆preSS独家现在;卡西尼一直缺乏特色和IIS防爆preSS避免我不必配置IIS的每个Web应用程序。

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/

解决方案

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.

这篇关于使用卡西尼与包含点的虚拟路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆