2016-05-17 70 views
0

从我的应用程序,我的数据库插入在云上的连接字符串,它工作得很好。但是,当我发布的应用程序,部署在一些托管,我得到poreview登录屏幕,但我不能登录(超时错误)。关于生产我不能登录ASP MVC 5 IDENTITY 2.0

我的配置文件看起来像这样:

<?xml version="1.0" encoding="utf-8"?> 

<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> 
<authentication mode="None" /> 
<compilation targetFramework="4.5" /> 
<httpRuntime targetFramework="4.5" /> 
</system.web> 
<system.webServer> 
<modules> 
    <remove name="FormsAuthentication" /> 
</modules> 
</system.webServer> 
<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin.Security" 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" 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" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.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.Optimization" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.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> 
    <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.3.0" newVersion="5.2.3.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> 
</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> 
<!--<appSettings> 
<add key="ClientValidationEnabled" value="true" /> 
<add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
</appSettings>--> 
<!--<appSettings> 
<add key="closeModal" value="False"/> 
</appSettings>--> 
</configuration> 

我有数据库称为 “DB_9F4064_SalesManagement”。所以,我把那DATABSE到Identity型号ApplicationDbContext():

public class ApplicationUser : IdentityUser 

{ 
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) 
    { 
     // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType 
     var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); 
     // Add custom user claims here 
     return userIdentity; 
    } 
    public string FirstName { get; set; } 
    public string LastName { get; set; } 
    public string NameSurname { get; set; } 
    public string Name 
    { 
     set 
     { 
      NameSurname = FirstName + " " + LastName; 
     } 
     } 
} 
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> 
{ 
    public ApplicationDbContext() 
     : base("DB_9F4064_SalesManagement", throwIfV1Schema: false) 
    { 
    } 
    public static ApplicationDbContext Create() 
    { 
     return new ApplicationDbContext(); 
    } 
} 

谁能告诉我哪里出了问题?

我应该放更多的代码?谢谢

+0

当您发布,你指定一个数据库连接字符串? – trailmax

+0

你确定你正在尝试登录的用户已经存在吗? – gldraphael

回答

0

在你的web.config中,你应该在配置标签中指定连接字符串。下面是一个示例:

<connectionStrings> 
    <add name="ConnectionStringName" connectionString="data source=YourDbServerIp;initial catalog=DB_9F4064_SalesManagement;user id=loginUsername;password=loginPassword;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 

然后你ApplicationDbContext构造是这样的:

public ApplicationDbContext() 
: base("name=ConnectionStringName", throwIfV1Schema: false){}