我如何注册已在一个领域已经创建了一个控制器 [英] How do I register a controller that has been created in an AREA

查看:182
本文介绍了我如何注册已在一个领域已经创建了一个控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MVC4的Web API揭露的控制器。

I am using MVC4's WEB API to expose a controller.

起初我创建创建MVC4的WebAPI项目,将项目不打开任何网页,等待外部应用程序调用的URL(WEB API)。在VS2010的项目设置为从IIS7防爆preSS,不是VS2010的开发服务器上运行。该工程确定,浏览器提示我下来加载文件。这对我来说是OK,因为浏览器不知道如何处理返回的数据做(原始文本)。

Initially I created created a MVC4 WEBAPI project, set the project not to open any web page, wait for an external app to call the URL (WEB API). The project in VS2010 is set to run from IIS7 Express, not VS2010's Dev Server. This works OK, the browser prompts me to down load a file. Which is OK for me, as the browser does not know what to do with the returned data (RAW TEXT).

接下来,我在MVC4项目区创建的区域,然后添加一个控制器(WEB API类型)。

Next, I created an AREA in the MVC4 project area, then added a controller (WEB API type).

然后我再次跑项目,并在浏览器中输入的URL(WEB API)。而它失败。

Then I once again ran the project and in a browser entered the the URL (WEB API). And it fails.

推荐答案

该DefaultHttpControllerFactory不与默认领域的工作。要获得此功能,您必须编写自定义HttpControllerFactory。

The DefaultHttpControllerFactory doesn't work with Areas by default. To get this functionality you have to write your custom HttpControllerFactory.

您可以找到如何在后的如何创建HttpControllerFactory支持领域

You can find how to do this at the post How to create HttpControllerFactory to support Areas

这篇关于我如何注册已在一个领域已经创建了一个控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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