「投稿」で問題が発生しています。ユーザー オブジェクトが常に null になっています。私は機知に富んでおり、これを何日も調査してきました。アイデアがあれば、助けてください。前もって感謝します
私のJqueryは次のようになります
$(document).ready(function () {
$("#register").click(function (e) {
e.preventDefault(); //stop the submit event for the submit button
var Name = $("#register_username").val();
var Email = $("#register_email").val();
var Password = $("#register_password").val();
var Contact = $("#register_contactNumber").val();
var Adress = "Seteelte Town";
var chkUserType = document.getElementById("identity_type_2").checked;
var userinfo = { "request": { "Action": { "Address": Adress, "Children": [], "CityId": 0, "Email": Email, "HomeUser": chkUserType, "ImagePath": "", "IpAdress": "", "IsActive": false, "LastLogin": "", "Name": Name, "Password": Password, "PhoneNumber": Contact, "ProfileHit": 0, "ShowEmail": false, "ShowPhoneNumber": false, "SubscribeNews": false, "UserID": 0}} };
alert("Input: " + JSON.stringify(userinfo));
$.ajax({
type: "POST",
url: '/Services/Membership.svc/AccountAdd',
data: JSON.stringify(userinfo),
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.Result);
},
error: onError
});
});
});
私のWCF用のC#コードは
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Membership : IMembership
{
public SMProcessResponse<bool> AccountAdd(SMProcess<User> request)
{
return new SMProcessResponse<bool>(MembershipController.AccountAdd(request.Action));
}
}
プロセスリクエストのC#コードは
[DataContract(Namespace = "")]
public class SMProcess<T> : BaseRequest
{
public SMProcess(T obj)
{
// TODO: Complete member initialization
this.Action = obj;
}
[DataMember]
public T Action { get; set; }
}
ここに私のWeb.configがあります
<configuration>
<connectionStrings>
//here is connection string
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.serviceModel>
<services>
<service name="SelectionMall.Services.Membership">
<endpoint address="" behaviorConfiguration="Services.webHttpBehavior" binding="webHttpBinding" contract="SelectionMall.Services.IMembership" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Services.webHttpBehavior">
<webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>