不能调试在MVC2项目视图,让"资源无法找到"错误 [英] Cannot debug views in MVC2 project, getting "The resource cannot be found" error

查看:185
本文介绍了不能调试在MVC2项目视图,让"资源无法找到"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行Visual Studio 2008 SP1 Win7上,安装了MVC2 RTM。

I'm running Visual Studio 2008 sp1 on Win7, with MVC2 RTM installed.

我创建使用向导创建新项目MVC2和我无法调试特定页面。随着WebForms和甚至MVC1,我能坐在View页面上,按F5键,然后有集成的Web服务器VS2008我工作在页面上启动。非常方便的建立应用程序的逻辑。

I created a new MVC2 project using the wizard and am unable to debug specific pages. With webforms and even MVC1, I was able to sit on a View page, hit F5, and then have the integrated web server in VS2008 start on the page I was working on. Very handy for building up app logic.

当我尝试这个现在我得到一个的资源不能找到错误页面。

When I try this now I get a "The resource cannot be found" error page.

我和股票新MVC2 Web应用程序项目刚才试这个。下面是我创建新项目重现之后采取的步骤:

I retried this just now with a stock new MVC2 Web Application project. Here are the steps I took after creating the new project to reproduce:


  1. 打开了项目设置。在Web子选项卡中,启动操作设置为当前页。保留所有其他设置不变。

  2. 的意见了打开其中一个(例如账户/ Register.aspx)

  3. 按F5调试项目

  4. 请注意,这显示在浏览器窗口显示错误消息的资源不能找到。

我看到的链接在我的浏览器这个运行是:的http://本地主机:49471 /查看/帐号/ Register.aspx

The link I saw in my browser for this run was: http://localhost:49471/Views/Account/Register.aspx

我做了一些谷歌搜索,发现与确保所有HTTP安装了服务器片的建议。我仔细检查了并且确信,HTTP错误和HTTP重定向是两个安装。

I did some googling and found suggestions related to ensuring all HTTP server pieces were installed. I double checked and made sure that "HTTP Errors" and "HTTP Redirection" were both installed.

如果我离开的项目设置,因为它本来,设置为特定页什么也没有在文本框中,然后布线工程,我总是得到默认主页。我希望这不是唯一的选择。

If I leave the project setting as it was originally, set to "Specific Page" with nothing in the text box, then routing works and I always get the default home page. I'm hoping this isn't the only option.

谢谢!

推荐答案

通常情况下,资源无法找到(这是一个HTTP 404)在ASP.NET MVC表明某种路由的问题。

Generally, the "resource cannot be found" (which is an HTTP 404) in ASP.NET MVC indicates some kind of routing problem.

在开始操作设置为一个页面(任何页面)可能是为什么你有这个问题。据我所知,这总是会产生404,因为MVC项目不做的网页,他们做的动作。

Setting the Start Action to a page (any page) is probably why you're having this problem. AFAIK, this will always cause a 404 because MVC projects don't do pages, they do Actions.

尝试清除开始行动 - 你再应该看到Index操作/视图页面拿出当您运行该项目。展望未来,如果你想要去一​​个特定的控制器操作在启动时,输入[ControllerName] / [动作]在开始行动没有一个.aspx页面名称。

Try clearing the Start Action- you should then see the Index action/view "page" come up when you run the project. Going forward, if you want to go to a particular Controller Action on startup, enter the [ControllerName]/[Action] in the Start Action without an .aspx page name.

这篇关于不能调试在MVC2项目视图,让"资源无法找到"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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