2014-12-18 3 views
0

나는 현재 어떻게 움직이는 지 모르겠다. 현재 작업중인 웹 사이트에 로그인 한 사용자가 없으면 DB 정보를 사용해야하는 페이지에 액세스 할 수 있습니다. 하지만 로그인 할 때 제목에 오류가 표시됩니다."SQL Server에 연결하는 동안 네트워크 관련 또는 인스턴스 관련 오류가 발생했습니다."

무료 평가판을 사용하여 내 데이터베이스와 웹 사이트를 Azure 클라우드 서비스를 통해 호스팅하고 있으며 또한 web.config에서 역할 관리자를 사용하도록 설정했습니다 (사용 중지하면 오류가 제거되지만 역할 검사를 사용하도록 설정해야합니다). 내가 localhost에있을 때 모든 것이 잘 작동하므로 내 웹 사이트가 배포 될 때만 문제가 발생합니다.

저는 ASP.NET에 익숙하지 않아 어떻게 작동하는지 몇 가지 기본 지식을 잃어 버렸습니다.

** 편집 : timeiscoffee에서 여기

<?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=301880 
    --> 
<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=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-Entertainist-20141207110857.mdf;Initial Catalog=aspnet-Entertainist-20141207110857;Integrated Security=True" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <appSettings> 
    <add key="webpages:Version" value="3.0.0.0" /> 
    <add key="webpages:Enabled" value="false" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    </appSettings> 
    <system.web> 
    <customErrors mode="Off" /> 
    <authentication mode="None" /> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    <roleManager enabled="true" 
    defaultProvider="SqlRoleProvider"> 
     <providers> 
     <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" 
     connectionStringName="DefaultConnection" 
     applicationName="Entertainist"/> 
     </providers> 
    </roleManager> 
    <globalization culture="en-US" uiCulture="auto:en-US" /> 
    </system.web> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <remove name="FormsAuthentication" /> 
    </modules> 
    </system.webServer> 

    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="CalculatorServiceBehavior"> 
      <serviceAuthorization principalPermissionMode="UseAspNetRoles" 
           roleProviderName="SqlRoleProvider" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 


    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <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="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> 
     </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> 
</configuration> 

와 추가 된 코드를 사용하여 내 web.config 파일은 역할을 설정하고 데이터베이스

에 시드 데이터를 추가 내 Configuration.cs 파일은 ** 여기입니다
namespace Entertainist.Migrations 
{ 
    using Entertainist.Models; 
    using Microsoft.AspNet.Identity; 
    using Microsoft.AspNet.Identity.EntityFramework; 
    using System; 
    using System.Data.Entity; 
    using System.Data.Entity.Migrations; 
    using System.Linq; 

    internal sealed class Configuration : DbMigrationsConfiguration<Entertainist.Models.ApplicationDbContext> 
    { 
     public Configuration() 
     { 
      AutomaticMigrationsEnabled = true; 
      ContextKey = "Entertainist.Models.ApplicationDbContext"; 
     } 

     protected override void Seed(Entertainist.Models.ApplicationDbContext context) 
     { 

      var UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context)); 
      var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context)); 

      // Create Admin Role 
      string roleName = "Admins"; 
      IdentityResult roleResult; 

      // Check to see if Role Exists, if not create it 
      if (!RoleManager.RoleExists(roleName)) 
      { 
       roleResult = RoleManager.Create(new IdentityRole(roleName)); 
      } 

      context.Artists.AddOrUpdate(
       a => a.ArtistName, 
       new Artist { ArtistName = "Kanye West" }, 
       new Artist { ArtistName = "65daysofstatic"}, 
       new Artist { ArtistName = "D'Angelo"}, 
       new Artist { ArtistName = "Faith No More"}, 
       new Artist { ArtistName = "Daft Punk" }, 
       new Artist { ArtistName = "Lana Del Rey"}, 
       new Artist { ArtistName = "The Decemberists"}, 
       new Artist { ArtistName = "The War On Drugs"} 
       ); 

      context.MusicGenres.AddOrUpdate(
       g => g.GenreName, 
       new MusicGenre { GenreName = "Rock" }, 
       new MusicGenre { GenreName = "Hip-Hop" }, 
       new MusicGenre { GenreName = "Electronic" }, 
       new MusicGenre { GenreName = "Country" }, 
       new MusicGenre { GenreName = "Classical" }, 
       new MusicGenre { GenreName = "Indie"}, 
       new MusicGenre { GenreName = "Rap"}, 
       new MusicGenre { GenreName = "Metal"}, 
       new MusicGenre { GenreName = "Pop"} 
       ); 

      context.MovieGenres.AddOrUpdate(

       g => g.GenreName, 
       new MovieGenre { GenreName = "Adventure"}, 
       new MovieGenre { GenreName = "Action"}, 
       new MovieGenre { GenreName = "Anime"}, 
       new MovieGenre { GenreName = "Bollywood"}, 
       new MovieGenre { GenreName = "Sci-Fi"}, 
       new MovieGenre { GenreName =" Independent"}, 
       new MovieGenre { GenreName = "Fantasy"} 

       ); 


      context.Studios.AddOrUpdate(
       s => s.StudioName, 
       new Studio { StudioName = "Universal"}, 
       new Studio { StudioName = "MGM"}, 
       new Studio { StudioName = "Disney"}, 
       new Studio { StudioName = "Bad Robot"}, 
       new Studio { StudioName = "Studio Ghibli"}, 
       new Studio { StudioName = "Pixar"} 
       ); 

      context.Directors.AddOrUpdate(
       d => d.DirectorName, 
       new Director { DirectorName = "Steven Spielberg"}, 
       new Director { DirectorName = "Michael Bay"}, 
       new Director { DirectorName = "James Cameron"}, 
       new Director { DirectorName = "Ang Lee"}, 
       new Director { DirectorName = "J.J. Abrams"}, 
       new Director { DirectorName = "Hayao Miyazaki"} 

       ); 

      // This method will be called after migrating to the latest version. 

      // You can use the DbSet<T>.AddOrUpdate() helper extension method 
      // to avoid creating duplicate seed data. E.g. 
      // 
      // context.People.AddOrUpdate(
      //  p => p.FullName, 
      //  new Person { FullName = "Andrew Peters" }, 
      //  new Person { FullName = "Brice Lambson" }, 
      //  new Person { FullName = "Rowan Miller" } 
      // ); 
      // 
     } 
    } 
} 
+0

새로운 내용은 잘 알고 있습니다. 지금까지 가지고있는 코드 중 일부를 사람들에게 보여줄 수있는 마음을 보여 주시겠습니까? – CalebB

답변

0

하늘 구름 서비스의 데이터베이스를 사용하려면 RoleProvider을 확장 한 적이 있습니까? 그렇지 않다면 sqlexpress를 사용하려고 시도했을 것입니다. sqlexpress는 현지에서 작동하지만 배포 할 때 작동하지 않는 이유입니다.

http://msdn.microsoft.com/en-us/library/aa702542(v=vs.110).aspx

+0

지정한 링크에 있던 코드를 추가했는데 "저장 프로 시저 'dbo.aspnet_CheckSchemaVersion'을 찾을 수 없습니다."라는 새로운 오류가 나타납니다. " – jarrodthibodeau

+0

스키마를 설정하기 위해 대상 데이터베이스에 대해 aspnet_regsql.exe를 실행해야하는 것처럼 들립니다. –

관련 문제