小编Nae*_*aza的帖子

服务栈:类型定义应该以'{'开头,期望序列化类型'AuthResponse',从字符串开始

我正在使用以下代码来验证用户在我的asp.net应用程序中使用ServiceStack基本身份验证提供程序并接收serration异常.如果有人解决了这个问题,请回答.谢谢.

我在我的asp.net应用程序中使用以下代码:

<asp:Button ID="btnAuth" runat="server" OnClick="btnAuth_Click" Text="Authenticate"/>
Run Code Online (Sandbox Code Playgroud)

我在代码隐藏文件中的clien.Post方法上收到异常.

protected void btnAuth_Click(object sender, EventArgs e)
        {
            try
            {                
                var baseUrl = Request.Url.GetLeftPart(UriPartial.Authority) + "/api";
                var client = new JsonServiceClient(baseUrl);
                var authResponse = client.Post<AuthResponse>(new Auth { UserName = "admin", Password = "12345" });
                if (authResponse.ResponseStatus.ErrorCode == null)
                {
                   //Do Something here
                }
            }
            catch (WebServiceException ex)
            {
                throw ex;
            }
        }
Run Code Online (Sandbox Code Playgroud)

Followin是我在clien.Post方法上收到的Exeception Detail :

[SerializationException: Type definitions should start with a '{', expecting serialized type 'AuthResponse', got string …
Run Code Online (Sandbox Code Playgroud)

asp.net servicestack

5
推荐指数
1
解决办法
2284
查看次数

标签 统计

asp.net ×1

servicestack ×1