ASP.NET MVC4 응용 프로그램에서 단순 멤버쉽을 구현했습니다. 하지만 이제는 사용자 생성을 구현하고 로그인을 확인해야합니다.WindowsForms에서 SimpleMembership을 사용하여 HttpContext가 null 인 이유는 무엇입니까?
그래서 최근 프로젝트의 일부 코드를 복사하기 시작했습니다.
개체 참조가 개체의 인스턴스로 설정되지 않았습니다 : 예으로이 오류는 말한다
WebSecurity.InitializeDatabaseConnection("SimpleMembershipConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); bool val = WebSecurity.Login("1010", "pass"); // here throws the exception
충돌하는 부분입니다. 매개 변수 이름 : httpContext.
또한, 난 그냥 내 전체의 app.config 이것은 WebMatrix.WebData, WebMatrix.Data 및 System.Web
같은 일부 라이브러리를 가져
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
...
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<roleManager enabled="true" defaultProvider="simple">
<providers>
<clear />
<add name="simple" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData" />
</providers>
</roleManager>
<membership defaultProvider="simple">
<providers>
<clear />
<add name="simple" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
</providers>
</membership>
방법 HttpContext에서 null을 얻지 못하는 것에 대한 예외를 수정할 수 있습니까?
분명히 밝혀야 할 질문은 창문 형태입니다. winforms 응용 프로그램에서 웹 보안 모듈을 사용하려고합니까? – nunespascal
'HttpContext'는 ** ASP.NET ** 구조입니다 - ** 웹 애플리케이션에만 존재합니다 ** ** Winforms는 분명히 없습니다 ..... –
@nunespascal 아니오, 아직 –