ASP.NET MVC2:找不到控制器 [英] ASP.NET MVC2: Can't find controller

查看:678
本文介绍了ASP.NET MVC2:找不到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用领域的MVC 2.0网站。当我去的默认页(本地主机/ mywebsite / Default.aspx的),它正确路由到正确的控制器正确的行动和正确呈现的默认视图。

I have an MVC 2.0 web site that is using Areas. When I go to the default page (localhost/mywebsite/default.aspx), it correctly routes to the correct action in the correct controller and renders the default view correctly.

但是在网页我有几个Html.ActionLinks,这些似乎不能够找到的控制器。当我点击页面中的链接,我得到一个404错误。

But on the page I have several Html.ActionLinks, and these do not seem to be able to find the Controller. When I click on the links in the page, I get a 404 error.

的网址是什么,我希望:本地主机/ mywebsite / MyAreaName /首页/指数(例如)。我也试过本地主机/ mywebsite /地区/ MyAreaName /首页/指数,但是这也给了我一个404。

The URLs are what I expect: localhost/mywebsite/MyAreaName/Home/Index (for example). I've also tried localhost/mywebsite/Areas/MyAreaName/Home/Index, but this also gives me a 404.

我如何得到被认可的控制器?

How do I get the Controller to be recognized?

推荐答案

您可能没有你的IIS设置设置正确的请求正确映射。

You probably don't have your IIS settings setup correctly to map the requests correctly.

是IIS验证是否已设置了通配符应用程序映射

Is IIS verify that you have set the "Wildcard application maps" to:

c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll

和确保您有验证文件是否存在复选框的选中

And make sure you have the "Verify file exists" checkbox unchecked.

演练 - 阅读IIS6扩展名的网址

Walkthrough - read section "IIS6 Extension-less URLs"

替换文本

更多信息IIS 6 MVC设置

更多IIS信息

修改:由于您使用IIS 7,验证它是在集成模式下运行。如果在传统模式下运行的映射是不是就像IIS6工作方式自动完成的。

EDIT: Since your using IIS 7, verify that it is running in integrated mode. If it is running in classic mode the mapping is NOT done automatically just like the way IIS6 works.

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

这篇关于ASP.NET MVC2:找不到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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