小编Mah*_*V S的帖子

.net Core - 使用Route属性时未加载默认控制器

一个新的.net核心Web应用程序项目带有以下路由配置:

    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
Run Code Online (Sandbox Code Playgroud)

如果将其替换为HomeController及其操作(索引,关于,联系人,错误)并为其app.UseMvc()添加适当的Route属性,它仍然可以工作.由于我们没有指定默认路由,因此如果您点击http:// localhost:25137 /,则不会呈现默认视图(Home/Index).希望理解是正确的!

现在,因为我需要在http:// localhost:25137 /被命中时显示默认视图,所以我更改了路由代码app.UseMvcWithDefaultRoute();,根据定义,它将与初始代码段相同.即使这样,它也没有呈现默认视图; 但在使用完整的URL(http:// localhost:25137/home/index)时工作.这意味着路由仍然有效但不是默认路由!

然后我回到控制器并Route从HomeController及其动作中删除了所有属性.然后默认路由可以解决任何问题.

这是预期的行为吗?这种行为背后的原因是什么?

asp.net-mvc asp.net-mvc-routing asp.net-core-mvc .net-core

8
推荐指数
1
解决办法
9454
查看次数

PostgreSQL的CLUSTER与SQL Server中的聚簇索引有何不同?

许多像这样的stackoverflow链接的帖子声称PostgreSQL中没有聚集索引的概念.但是,PostgreSQL文档包含类似的内容.一些人声称它类似于SQL Server中的聚簇索引.

你知道这两者之间的确切区别是什么,如果有的话?

postgresql clustered-index

6
推荐指数
1
解决办法
1059
查看次数

如何检查 Azure SQL 数据库中是否已存在数据库用户

我的新客户计划使用 Azure 托管 SQL 数据库服务。我正在使用 dacpac 来部署数据库。在 dacpac 中,我有一个部署后脚本来创建一个 sql 用户,如下所示

IF NOT EXISTS (SELECT name
               FROM   sys.server_principals
               WHERE  name = 'myusername')
    BEGIN
        CREATE LOGIN myusername
            WITH PASSWORD = '******';
    END
GO
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试在 Azure(使用目标平台 - Microsoft Azure SQL 数据库 V12 编译)中应用 dacpac 时,它会引发以下错误。

An error occurred while the batch was being executed.
Updating database (Failed)
*** Could not deploy package.
Error SQL72014: .Net SqlClient Data Provider: Msg 208, Level 16, State 1, Line 4 Invalid object name 'sys.server_principals'.
Error SQL72045: …
Run Code Online (Sandbox Code Playgroud)

t-sql sql-server azure dacpac azure-sql-database

4
推荐指数
2
解决办法
4899
查看次数

Web组件Polyfill无法正常工作

我正在尝试按照https://www.webcomponents.org/polyfills/中的解释来填充web组件,因为我希望我的示例应用程序可以在Chrome和Firefox上运行.但是我得到了ReferenceError:Firefox中没有定义customElements错误.请参阅下面的index.html代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="robots" content="index, follow">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Sample</title>
    <link rel="stylesheet" href="css/site.css">
    <!-- Components -->
    <link rel="import" href="components/global/site-navigation.html">
</head>

<body>
    <script>
        (function () {
            if ('registerElement' in document
                && 'import' in document.createElement('link')
                && 'content' in document.createElement('template')) {
                // platform is good!
            } else {
                // polyfill the platform!
                var e = document.createElement('script');
                e.src = 'js/webcomponents.js';
                document.body.appendChild(e);
            }
        })();
    </script>
    <site-navigation></site-navigation>
</body>    
</html>
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

PS:Chrome中一切正常(有/无填充)

javascript web-component polyfills shadow-dom html-imports

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