2011-07-22 8 views
1

私は必死です。私はC#で開発したMVC RestサービスをHTTPSプロトコルに移行しようとしています。私はnormaly javaプログラマーです、私はwebappsの全体の構成、特に私に大きなミステリーweb.configファイルのいくつかの深刻な問題があることを認めます。MVCアプリケーションでhttpsを有効にする方法

だから、私の問題です。私はIIS 7上で動作している動作中のRest APIを持っています。私が理解したところでは、私はhttpsのためにサーバーにバインディングを追加する必要があります。だから私は私のカスタム証明書を作成し、バインディングを追加しました。 IISマネージャーでは、ここで2つのバインディング、httpとhttpsをバインドします。

しかし、私がこれをやろうとしたら、httpやhttpsでwebserviceにアクセスできませんでした。両方とも同じエラーが発生しました:

提供されたURIスキーム 'https'は無効です。期待される 'http'。 パラメータ名:context.ListenUriBaseAddress

このエラーを検出すると、web.configファイルでトランスポートセキュリティを設定する必要があることが示されました。私が持っている問題は、私の設定がどうにかしてhttpsの起動を含むすべての例の設定とは全く異なって見えるということです。

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <appSettings> 
    <add key="webpages:Version" value="1.0.0.0" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    </appSettings> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
     <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     </assemblies> 
    </compilation> 
    <authentication mode="None"></authentication> 

    <httpModules> 
     <add name="CustomBasicAuthenticationModule" type="DMAlertRestServer.Server.Authentificator" /> 
    </httpModules> 

    <pages> 
     <namespaces> 
     <add namespace="System.Web.Helpers" /> 
     <add namespace="System.Web.Mvc" /> 
     <add namespace="System.Web.Mvc.Ajax" /> 
     <add namespace="System.Web.Mvc.Html" /> 
     <add namespace="System.Web.Routing" /> 
     <add namespace="System.Web.WebPages" /> 
     </namespaces> 
    </pages> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    </system.webServer> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    </system.serviceModel> 

    <connectionStrings> 
    <add name="DBConnection" 
    connectionString=" 
    Data Source=XXXXX;Initial Catalog=DBAlarmTest;Integrated Security=False;User ID=XXX;Password=XXX;" 
    providerName="System.Data.SqlClient"/> 
    </connectionStrings> 
</configuration> 

これがどのように解決できるかは、本当に歓迎します。大変ありがとうございます

+0

このリンクが役立つかもしれないかどうかチェックしてください.http://stackoverflow.com/questions/156748/ssl-pages-underasp -net-mvc –

答えて

1

問題が見つかりました。 私はcodeplexのWCFライブラリを使用していました。 httpが有効な場合、httpsに失敗するバグがあります。 ルーティングコードをやり直すことで問題を回避することができます。 悲しいことに、私はaccidentally私の全体の.netプロジェクトを削除したので、投稿することはできません:(

関連する問題