小编Sky*_*rsZ的帖子

在 .Net Core 3.0 项目中正确设置 ASP.Net Core 授权和身份验证

我目前正在使用 VSCode 处理 .net 核心 api 项目,并且我想将 ASP.NET 核心身份验证和授权与 cookie 集成。

我试图添加services.AddAuthentication();services.AddAuthorization();Startup.cs。我还在[Authorize]我的UsersController.cs.

[Authorize]
    [Route("api/Users")]
    [ApiController]
    public class UsersController : ControllerBase
Run Code Online (Sandbox Code Playgroud)

问题是当我启动我的应用程序时,即使我没有创建用户或角色,我仍然可以访问我的 API。( https://localhost:5001/api/Users)

我尝试设置launchSettings.json如下:

  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": false,
    "iisExpress": {
      "applicationUrl": "http://localhost:49086",
      "sslPort": 44343
    }
Run Code Online (Sandbox Code Playgroud)

但我仍然可以访问我的 API。如果没有用户或角色,如何拒绝访问?

我肯定错过了一些东西,但我不知道是什么。

预先感谢您的帮助!

c# .net-core asp.net-core .net-core-3.0

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

如何数据绑定 textarea 组件文本值并更新它?

1 周前,我一直在为一个项目使用 VueJS。

我创建了两个组件: * Account.vue (Parent)

<!--It's just a little part of the code-->
 <e-textarea
    title="Informations complémentaires"
    @input="otherInformation" <!--otherInformation is a string variable which contains the text value-->
    :value="otherInformation"></e-textarea>
Run Code Online (Sandbox Code Playgroud)
  • TextArea.vue(子组件)
<template>
  <div class="form-group">
    <label for="e-textarea">{{ title }}</label>
    <textarea
      id="e-textarea"
      class="form-control"
      row="3"
      :value="value"
      v-on="listeners"
    >
    </textarea>
  </div>
</template>
<script>
import { FormGroupInput } from "@/components/NowUiKit";

export default {
  name: "e-textarea",
  components: {
    [FormGroupInput.name]: FormGroupInput
  },
  props: {
    title: String,
    value: String
  },
  computed: {
    listeners() {
      return {
        ...this.$listeners, …
Run Code Online (Sandbox Code Playgroud)

html javascript mvvm vue.js vuejs2

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

标签 统计

.net-core ×1

.net-core-3.0 ×1

asp.net-core ×1

c# ×1

html ×1

javascript ×1

mvvm ×1

vue.js ×1

vuejs2 ×1