0

アプリケーションがDBに接続するためのaspwebapiを作成しました。ローカルホストで開発している間、すべてが正常に機能しています。しかし、公開後、メインページ以外には何も機能していません。公開後にルーティングが機能していないようです

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に変換しました。

更新 OK。コントローラで簡単に確認した後、空白のページが表示されます。エラーなし:/

チェックは、私のアクションがint番号「2」を返すことです。だから私は問題が実際のコードによって引き起こされていないことを知っています。しかし、今はエラーも何もありません。空白のページ

奇妙なことに、Firefoxは空白のページを返しますが、InternetExplorerはエラー500を返します


以下の回答

4

1 に答える 1

1

問題を見つけました!

.NET4.5から.NET4.0にバックロールしましたが、Entity Frameworkが5.0から4.3.1にバックロールしなかったため、v 5.0を手動でアンインストールしてから、NuGetから4.3.1をインストールする必要がありました。その後、すべてが機能し始めました!

于 2012-10-16T09:45:48.363 に答える