小编Yan*_*ang的帖子

如何让Owin自主主机支持Json输出?

我正在使用Owin构建一个支持文件请求和web api的自托管服务器.但是,web api请求的输出始终采用xml格式.如何在json中配置owin到输出?

代码如下:

class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseFileServer(new FileServerOptions()
        {
            RequestPath = PathString.Empty,
            FileSystem = new PhysicalFileSystem(@".\files")
        });

        // set the default page
        app.UseWelcomePage(@"/index.html");

        HttpConfiguration config = new HttpConfiguration();

        config.Routes.MapHttpRoute
        (
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional } 
        );

        app.UseWebApi(config);
    }
}
Run Code Online (Sandbox Code Playgroud)

asp.net

22
推荐指数
1
解决办法
9961
查看次数

如何使用资源所有者流与javascript客户端从IdentityServer3添加对访问令牌的声明

我使用IdentityServer3的资源所有者流,并使用javascript中的用户名和密码将get token请求发送到身份服务器令牌端点,如下所示:

        function getToken() {
        var uid = document.getElementById("username").value;
        var pwd = document.getElementById("password").value;
        var xhr = new XMLHttpRequest();
        xhr.onload = function (e) {
            console.log(xhr.status);
            console.log(xhr.response);
            var response_data = JSON.parse(xhr.response);
            if (xhr.status === 200 && response_data.access_token) {
                getUserInfo(response_data.access_token);
                getValue(response_data.access_token);
            }
        }
        xhr.open("POST", tokenUrl);
        var data = {
            username: uid,
            password: pwd,
            grant_type: "password",
            scope: "openid profile roles",
            client_id: 'client_id'
        };
        var body = "";
        for (var key in data) {
            if (body.length) {
                body += "&";
            }
            body += key + …
Run Code Online (Sandbox Code Playgroud)

openid oauth-2.0 asp.net-web-api identityserver3 identityserver2

9
推荐指数
2
解决办法
1万
查看次数

如何使Angular ui网格最初扩展所有行?

我正在使用ui网格显示数据列表,我正在尝试初始扩展所有行.

我试图在onRegisterApi事件中执行此操作:

scope.GridOptions =
        {
            data: properties,
            columnDefs: 
            [
                { name: "Full Address", field: "FullAddress" },
                { name: "Suburb", field: "Suburb" },
                { name: "Property Type", field: "PropertyType" },
                { name: "Price", field: "Price", cellFilter: 'currency'},
                { name: "Status", field: "Status" },
                { name: "Sale Type", field: "SaleType" }, 
                { name: "Date Created", field: "CreateDate", cellFilter: "date:'dd/MM/yyyy HH:mma'"}
            ],
            expandableRowTemplate: 'template.html',
            expandableRowHeight: 200,
            onRegisterApi: (gridApi) => 
            {
                scope.gridApi = gridApi;
                gridApi.expandable.on.rowExpandedStateChanged(scope,(row) =>
                {
                    if (row.isExpanded) {
                        this.scope.GridOptions.expandableRowScope = row.entity;
                    } …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui angular-ui-grid

8
推荐指数
2
解决办法
9350
查看次数

如何在可扩展行模板中访问ui网格行数据?

我正在尝试使用自定义的可扩展模板实现可扩展的ui网格.如何访问模板中的行数据?

在控制器中,我定义了这样的网格选项:

            scope.GridOptions =
            {
                data: customers,
                columnDefs:
                [
                    { name: "FirstName", field: "FirstName", width: 130 },
                    { name: "LastName", field: "LastName", width: 130 }
                ],
                expandableRowTemplate: 'CustomerDetails.html',
                expandableRowHeight: 150
            };
Run Code Online (Sandbox Code Playgroud)

模板如下:

<div class="row">
    <div class="col-md-2">
        {{FirstName}} {{LastName}}
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

谢谢!

angularjs angular-ui-grid

3
推荐指数
1
解决办法
3584
查看次数