在azure上发布后无法运行webapi

时间:2012-10-15 22:06:31

标签: asp.net azure asp.net-web-api

我为我的应用程序创建了一个用于连接数据库的asp webapi。在localhost上进行开发时,一切正常。但是在发布之后没有任何东西在主页旁边工作看起来我的路由在发布后无法正常工作

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "sd/{controller}/{action}"
        );

        routes.MapHttpRoute(
            name: "ParamApi",
            routeTemplate: "sd/{controller}/{action}/{param}",
            defaults: new { param = RouteParameter.Optional }
        );

        routes.MapHttpRoute(
            name: "GuestApi",
            routeTemplate: "sd/{controller}/{action}/{username}/{password}/",
            defaults: new
            {
                username = UrlParameter.Optional,
                password = UrlParameter.Optional
            }
        );

        routes.MapHttpRoute(
            name: "BriefcasePutApi",
            routeTemplate: "sd/{controller}/{action}/{id}/{value}/{owner}",
            defaults: new { 
                id = RouteParameter.Optional,
                value = RouteParameter.Optional,
                owner = RouteParameter.Optional
            }
        );

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

只有在发布后才能使用的是名为Default的路线。其余的都没有。我得到这样的错误:

Server Error in '/' Application.

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.\r\n

 Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".`

当我调用url时遇到此错误:http://domain.com/sd/content/get

在我的本地主机上,它完全正常,但在发布后不适用于天蓝色

我可能错了,这是路由问题,但我不知道我还能在哪里看。

我在.NET 4.5中创建了项目,但之后我发现我还没有在azure上使用它,所以我把它转换为4.0

更新 好。用控制器快速检查后,我得到空白页。没有错误:/

检查是我的动作返回int数字“2”。所以我知道问题不是由一些代码在行动引起的。但现在我没有错误,没有任何错误。只是空白页

奇怪的是:Firefox返回空白页但Internet Explorer返回错误500


以下答案

1 个答案:

答案 0 :(得分:1)

我发现了问题!

我已经从.NET 4.5回归到.NET 4.0但是实体框架没有从5.0回溯到4.3.1所以我不得不手动卸载v 5.0然后从NuGet我必须安装4.3.1。之后一切都开始起作用了!