本文介绍了asp.net mvc身份验证仅在调试时有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net mvc应用程序,在Visual Studio下运行良好,但是当我将其发布到本地主机时,我无法登录.

I have an asp.net mvc application that works fine under visual studio but when I publish it to the localhost, I'm unable to login.

我已经精简了代码,发现MembershipService.ValidateUser(model.UserName, model.Password)不起作用,但是下一行FormsService.SignIn(model.UserName, model.RememberMe)可以正常工作.

I already striped down the code and found that MembershipService.ValidateUser(model.UserName, model.Password) won't work but the next line FormsService.SignIn(model.UserName, model.RememberMe) works fine.

在网络配置中,我得到了以下信息:

On the web config I got the following:

<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <clear/>
    <add autogenerateschema="true"
             connectionStringName="ConnString"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             requiresUniqueEmail="false"
             passwordFormat="Hashed"
             maxInvalidPasswordAttempts="5"
             minRequiredPasswordLength="6"
             minRequiredNonalphanumericCharacters="0"
             passwordAttemptWindow="10"
             passwordStrengthRegularExpression=""
             applicationName="/"
             name="MySqlMembershipProvider"
             type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </providers>
 </membership>
 <profile defaultProvider="MySqlProfileProvider">
   <providers>
     <clear/>
     <add name="MySqlProfileProvider"
             type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"
             connectionStringName="ConnString" applicationName="/" autogenerateschema="true"/>
    </providers>
  </profile>
  <roleManager enabled="true" defaultProvider="MySqlRoleProvider">
    <providers>
      <clear/>
      <add name="MySqlRoleProvider" autogenerateschema="true" connectionStringName="ConnString" applicationName="/"
             type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
      </providers>
   </roleManager>

ConnString没问题,因为应用程序的其他部分工作正常(包括FormsService.SignIn).

The ConnString is ok because other parts of the application work just fine (including the FormsService.SignIn).

Visual Studio调试应用程序的物理路径在哪里,以便我可以将Web.configs与本地IIS上的Web.configs进行比较?

Where's the physical path where Visual Studio debug applications so I can compare Web.configs with the one on my localhost IIS?

推荐答案

我能够找到问题所在,实际上有点令人尴尬.

I was able to found the problem, it was kinda embarrassing actually.

我当时使用框架4.0构建该项目,但是正在使用.net framework 2.0将其部署到应用程序池中.

I was building the project with framework 4.0 but was deploying it to a Application pool using .net framework 2.0.

尽管我仍然发现ValidateUser方法依赖于框架,这很奇怪

Though I still find strange that the ValidateUser method depends on the framework

这篇关于asp.net mvc身份验证仅在调试时有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 01:46