2016-11-15 12 views
4

私のアプリケーションで要素を隠す役割を使用しようとしていますが、これは開発環境のVisual Studio Expressで正常に動作しています。しかし、サイトを公開してライブ環境に入れると、SQL Serverインスタンスに接続できないというエラーが表示されます。asp.netロールマネージャエラー

いくつかの人々は、この記事では、同じことのコメントのように見えます:The Role Manager feature has not been enabled

を私はそのコメントに対する解決策が表示されません。

web.configのroleManager enabled = "true"コードを削除すると、コントロールを隠すように見えるコードがあるところまでサイトが接続され、その後ロールマネジャーに関するエラーが有効になりません。

ここに私のweb.configファイルがありますが、これを正しく動作させる方法がわかりません。それでもWebプログラミングの多くにnoobの:

<?xml version="1.0" encoding="utf-8"?> 
<!-- 
For more information on how to configure your ASP.NET application, please visit 
http://go.microsoft.com/fwlink/?LinkId=169433 
--> 
<configuration> 
<configSections> 
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
</configSections> 
<connectionStrings> 
<add name="DefaultConnection" connectionString="Data Source=S192-169-136-24\ABPATH;Initial Catalog=aspnet-cs1-20160511031253;Integrated Security=True" providerName="System.Data.SqlClient" /> 
<add name="CS1" connectionString="Data Source=S192-169-136-24\ABPATH;Initial Catalog=CS1;Integrated Security=True" providerName="System.Data.SqlClient" /> 
</connectionStrings> 
<system.web> 
<authentication mode="None" /> 
<compilation targetFramework="4.5.2" /> 
<httpRuntime maxRequestLength="2097151" targetFramework="4.5.2" requestValidationMode="2.0" requestPathInvalidCharacters="" /> 
    <pages validateRequest="false"> 
    <namespaces> 
    <add namespace="System.Web.Optimization" /> 
    <add namespace="Microsoft.AspNet.Identity" /> 
    </namespaces> 
    <controls> 
    <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" /> 
    </controls> 
</pages> 
<membership> 
    <providers> 
    <!-- 
     ASP.NET Membership is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template 
    --> 
    <clear /> 
    </providers> 
</membership> 
<profile> 
    <providers> 
    <!-- 
     ASP.NET Membership Profile is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template 
    --> 
    <clear /> 
    </providers> 
</profile> 
<roleManager defaultProvider="DefaultConnection" enabled="true"> 
<providers> 
    <add name="DefaultConnection" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=NUMBER" connectionStringName="DefaultConnection" applicationName="/" /> 
</providers> 
</roleManager> 
<!-- 
     If you are deploying to a cloud environment that has multiple web server instances, 
     you should change session state mode from "InProc" to "Custom". In addition, 
     change the connection string named "DefaultConnection" to connect to an instance 
     of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express. 
    --> 
    <sessionState mode="InProc" customProvider="DefaultSessionProvider"> 
    <providers> 
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" /> 
    </providers> 
</sessionState> 
    <httpModules> 
    <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> 
</httpModules> 
</system.web> 
<system.webServer> 
<rewrite> 
    <rules> 
    <rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions> 
     <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
    </conditions> 
    <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" /> 
    </rule> 
    </rules> 
    </rewrite> 
    <modules> 
    <remove name="FormsAuthentication" /> 
    <remove name="ApplicationInsightsWebTracking" /> 
    <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> 
</modules> 
<validation validateIntegratedModeConfiguration="false" /> 
    <httpRedirect enabled="false" destination="https://www.pathcertlink.com/" exactDestination="true" /> 
</system.webServer> 
<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /> 
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" /> 
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
<entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    <providers> 
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <system.codedom> 
<compilers> 
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> 
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> 
    </compilers> 
</system.codedom> 
</configuration> 
+0

ロールプロバイダが原因で問題が解決してもよろしいですか?エラーは、接続文字列でWindows認証を使用しているためです: 'Integrated Security = True'です。したがって、最初に ''の下で偽装 ''を有効にする必要があります。 [Windowsの統合セキュリティを使用してSQL Serverにアクセスする方法](https://msdn.microsoft.com/en-us/library/bsz5788z.aspx)を参照してください。 –

+0

@RezaAghaei問題のアプリケーションはインターネット上にあります。イントラネットですが、開発環境が明らかにイントラネットであるため、何かに就いている可能性があります。私はWebアプリケーションを作成するのが初めてです(これは私の最初の話です)。インターネットで動作するようにweb.configを変更することは私には新しいものです。アプリケーションのユーザーはアプリケーションにのみログインしますが、組織との他の関連付けはないため、Windowsアカウントはまったくありません。 web.configを変更する必要がある場合は、その方法を知る必要があります。 –

+0

あなたは 'DefaultRoleProvider'に* Windows認証*を使用しています。つまり、アプリケーションを実行するアカウント(アプリケーションプールIDまたは偽装されたユーザー)は、Windows認証を使用してデータベースにアクセスする必要があります。それ以外の場合は、接続文字列をSQL Server認証に変更する必要があります。リモートデータベースの場合、Windows認証を使用する場合は、リモートデータベースにアクセスするドメインユーザーアカウントが必要です。ローカルデータベース(アプリケーションサーバーマシンと同じマシン)では、データベースにアクセスするローカルユーザーアカウントが必要です。 –

答えて

4

は、私はあなたがおそらくlocalhostまたはホスティングプロバイダによって提供されるIPアドレスにそれを変更する必要があるサーバーがLAPTOP-168YQ32

と呼ばれているとは思いません。私はまた、統合されたセキュリティを使用するとは思わないが、ユーザー名とパスワードの組み合わせが必要です。

接続文字列は次のようになります。

<add name="DefaultConnection" connectionString="Data Source=192.168.0.101;Initial Catalog=aspnet-cs1-20160511031253;User ID=userName;Password=passWord" providerName="System.Data.SqlClient"/> 
+0

はUser ID = userName; Password = passWordへの変更を試みました。 "userName"のログインが失敗すると誰もサイト期間にログインできません。これは何か単純なものでなければならないが、それが何であるべきか分からないことを知っている。 –

+0

また、リストされたWeb設定は私の開発環境からのものです。ライブサイトの接続文字列はIP経由のライブサーバを指していますが、上記のように構成された統合セキュリティを持っています。 –

+0

SQLサーバーの構成を確認し、ユーザー名とパスワードの組み合わせを受け付けるかどうかを確認します。また、統合されたセキュリティが本当にオプションではない場合、あなたのウェブサイトは社内サーバー上でホストされています。 – VDWWD

1

あなたのロールマネージャーのセクションは少し奇妙に見えます。 アセンブリトークンの "NUMBER"とは何ですか?また

、それはまた、接続の名前であるとして、ロール・マネージャに「DefaultConnectionを」よりも別の名前を付け、この時点で試してみる価値が詳しく、あるかもしれないことは

これを試してみてください:

<roleManager defaultProvider="DefaultRoleProvider"> 
    <providers> 
    <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/> 
    </providers> 
</roleManager> 

も、私はあなたが2つの接続

<connectionStrings> 
<add name="DefaultConnection" connectionString="Data Source=S192-169-136-24\ABPATH;Initial Catalog=aspnet-cs1-20160511031253;Integrated Security=True" providerName="System.Data.SqlClient" /> 
<add name="CS1" connectionString="Data Source=S192-169-136-24\ABPATH;Initial Catalog=CS1;Integrated Security=True" providerName="System.Data.SqlClient" /> 
</connectionStrings> 

を持つ接続で、私はRolemanagerは「DefaultConneを使用しながら、アプリケーションが接続「CS1」を使用していることが推測見ますそうでない場合 ASPNET-cs1-20160511031253、あなたはそれを追加、またはCS1にASPNETテーブルを追加し、変更します。あなたは、データベースのオンラインことを持っています「(ASPNET-cs1-20160511031253 『)

別のデータベースへのポイント』 ctionあなたのSQL Server接続ではないので、私はこの問題から、その複雑さを取り除くでしょう - DefaultConnectionを

<roleManager defaultProvider="DefaultRoleProvider"> 
    <providers> 
    <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="CS1" applicationName="/"/> 
    </providers> 
</roleManager> 
+0

これは実際に元の値に戻された以前のコメントからのものです。ロールマネージャーの役​​割が有効になるまで、アプリケーションはSQLサーバーに接続して使用しています。それには問題がありますが、ロールマネージャーだけが問題です。 Odd as rolesは、ロールマネージャを使用しないでメニュー項目を他の場所に表示/非表示するためにも使用されます。 –

+0

さて、私は答えを編集した、問題はあなたが間違った接続(CS1の代わりにDefaultConnection)を使用している可能性があります、答えの底を参照してください –

1

のCS1データベースisnteadを指すようにロールマネージャの役割ベースの認証では、すべてのWebサイト上でのユーザー認証についてです。あなたの問題は、単純で簡単なSQL Serverに接続できないことです。

この問題を解決するには、「SQL Serverに接続できません」と表示される特定のエラーメッセージを確認します。接続は拒否されていますか? (これは、SQL ServerがTCP/1433をリッスンしておらず、ソケットまたは一時ファイルのみを使用していることを意味します)。おそらく、パスワードが間違っている可能性があります。リモートサーバーで、RDP(リモートデスクトップ)を使用して、取得したアカウントのユーザー名とパスワードを使用してSQL Serverにログインできることを確認します。ほとんどの場合、通常は開発時に行われる統合セキュリティではなく、リモートサーバーで単純なユーザー名とパスワードを使用する必要があります。

+0

それは私が実際には得られないものです。アプリケーションが動作しており、私がロールマネージャーを有効にするまで、明らかにSQLデータベースに読み書きしています。私はこのことにとてもユニークで、なぜ接続できないのか分かりません。 –

+0

"rolemanager"を有効にし、現在のユーザーIDを使用してSQL Serverにログインするための統合セキュリティを追加すると、SQL Serverのログインが中断する可能性があります。私は内部を理解していませんが、ASP.net/IIS内のユーザーは実際に変更されています。 SQLサーバーにユーザー名とパスワードを追加し、この本番/ライブホストで「統合セキュリティ」を忘れることをお勧めします。 –