我正在使用ASP.NET 5构建一个使用Windows身份验证的Intranet类型站点.我有身份验证工作,但我不希望域中的每个人都可以访问Intranet站点.我无法使用域角色,因此我在SQL Server中设置了自己的自定义角色.我有一个表将域用户名映射到角色.我想将对Intranet站点的访问权限仅限于在我的SQL Server角色表中定义了角色的用户.如何在ASP.NET 5中为Windows身份验证设置自定义角色?谢谢!
asp.net authentication asp.net-mvc windows-authentication asp.net-core
我在同一个App Services实例中以两个虚拟应用程序托管在Azure App Services上的ASP.NET Core应用程序。主站点应用程序托管于/
,博客应用程序托管于/blog
。我想将AspNetCoreModuleV2与InProcess托管模型一起使用。但是,它无法启动,并且我在事件日志中看到此错误:
<Event>
<System>
<Provider Name="IIS AspNetCore Module V2"/>
<EventID>1008</EventID>
<Level>1</Level>
<Task>0</Task>
<Channel>Application</Channel>
...
</System>
<EventData>
<Data>
Only one inprocess application is allowed per IIS application pool. Please assign the application '/LM/W3SVC/170746742/ROOT/api' to a different IIS application pool.
</Data>
<Data>Process Id: 20236.</Data>
<Data>
File Version: 12.2.18296.0. Description: IIS ASP.NET Core Module V2. Commit: 61f1a70784dc0a32cf98f8ddd169c0293b0390ab
</Data>
</EventData>
</Event>
Run Code Online (Sandbox Code Playgroud)
如何使用InProcess托管模型在App Services中运行多个虚拟应用程序?
azure azure-web-sites .net-core azure-web-app-service asp.net-core
验证表单支持对象后,我得到一个BindingResult,其中包含FieldError的列表。每个FieldError都有一个defaultMessage。该消息集如何设置,为什么不使用Spring MessageSource?我希望该默认消息是从Spring的MessageSource派生的。
编辑: 我看到在FieldError对象中正确设置了错误代码。这只是该对象中的默认消息不是来自我的MessageSource。例如,当我为int字段输入字符串时,我希望它从messages.properties获取消息:
typeMismatch=Invalid type was entered.
Run Code Online (Sandbox Code Playgroud)
我可以获取该消息的唯一方法是,如果我将FieldError对象带入并手动将其传递到MessageSource中,如下所示:
messageSource.getMessage(fieldError, null); // This gets my message from messages.properties.
Run Code Online (Sandbox Code Playgroud) 以前,我可以使用JwtBearerAuthenticationOptions
自定义验证添加自定义令牌处理程序.现在使用Core UseJwtBearerAuthentication
我需要使用JwtBearerOptions
哪个似乎没有覆盖选项JwtSecurityTokenHandler
.我基本上想要覆盖以下方法JwtSecurityTokenHandler
:
protected virtual JwtSecurityToken ValidateSignature(string token, TokenValidationParameters validationParameters)
Run Code Online (Sandbox Code Playgroud)
先前:
app.UseJwtBearerAuthentication(new JwtBearerAuthenticationOptions
{
TokenHandler = new MyTokenHandler()
// other properties here
});
Run Code Online (Sandbox Code Playgroud)
目前使用ASP.NET Core:
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
// other properties here
});
Run Code Online (Sandbox Code Playgroud) 我有很多html表共享相同的15列以及特定于每个表的自定义列.我想创建这些常见的15列作为一个组件,它接收一组数据并显示为没有包装器的15 td.我无法弄清楚如何创建一个Angular组件,它不会在DOM中显示包装器标签,并允许我传入输入.以下是我想做的事情:
<tr *ngFor="let item of items">
<td>Column 1</td>
<my-common-columns [data]="item"></my-common-columns>
<td>Another column</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
不幸的是,使用上面的代码,<my-common-columns>
标记显示在渲染的DOM中,这会弄乱表格.我只能td
在tr
标签下面.
我也试过,<ng-container *ngComponentOutlet="myCommonColumns">
因为ng-container
没有出现在DOM中,但我无法弄清楚如何传入data
它.
我已在 Azure AD Premium 中设置了一个应用程序,并进行了访问该应用程序所需的用户分配。我已将自定义应用程序角色添加到应用程序清单中。我可以为应用程序分配具有角色的用户。
如何获得分配给应用程序的所有用户及其分配的角色的列表?
我有一个Angular组件,它侦听更改用户ID的route参数,并在加载时加载用户详细信息。用户详细信息需要花费几秒钟的时间才能从API返回数据。
如果我正在查看用户A的详细信息,然后单击以查看用户B的详细信息,它将继续显示用户A,直到单击后几秒钟返回用户B的详细信息。有什么方法可以显示正在加载的指示器,或者在为用户B检索数据时将其全部清空?
用户详细信息组件:
ngOnInit(): void {
this.userDetails = this.route.paramMap.pipe(
switchMap((params: ParamMap) => this.userService.getUserDetails(+params.get('userId')))
);
}
Run Code Online (Sandbox Code Playgroud)
用户详细信息模板:
<div *ngIf="userDetails | async as userDetails">
<h1>{{userDetails.firstName}} {{userDetails.lastName}}</h1>
</div>
Run Code Online (Sandbox Code Playgroud)
我希望用户详细信息div为空白或显示某种加载指示器(如果该内部switchMap当前正在运行)。我知道一个选项是在switchMap之前设置为true,在switchMap之后设置为false,并在div的* ngIf中使用该变量,但我希望可以采用一种轻松的方式为这些情况中的每一种加载变量。
我有一个StackBlitz示例:https ://stackblitz.com/edit/angular-ng-busy-yxo1gu
目的是当我单击用户B按钮时,在加载用户B时用户A信息应消失。我的应用程序中有数十种这种情况,因此我正在寻找最干净的方法。
我无法在messages.properties中获取我的消息,以便在我的表单支持对象的Spring验证期间使用.
APP-config.xml文件:
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages" />
</bean>
Run Code Online (Sandbox Code Playgroud)
WEB-INF /班/ messages.properties:
NotEmpty=This field should not be empty.
Run Code Online (Sandbox Code Playgroud)
表格支持对象:
...
@NotEmpty
@Size(min=6, max=25)
private String password;
...
Run Code Online (Sandbox Code Playgroud)
当我遍历BindingResult中的所有错误并输出ObjectError的toString时,我得到:
Field error in object 'settingsForm' on field 'password': rejected value []; codes [NotEmpty.settingsForm.password,NotEmpty.password,NotEmpty.java.lang.String,NotEmpty]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [settingsForm.password,password]; arguments []; default message [password]]; default message [may not be empty]
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,默认消息是"可能不为空"而不是我的消息"此字段不应为空".
如果我将messageSource注入控制器并输出它,我会得到正确的消息:messageSource.getMessage("NotEmpty",new Object [] {"password"},"default empty message",null);
那么为什么不使用我的messages.properties进行验证呢?我正在运行Spring 3.1.1.谢谢!
我使用jQuery和jQuery UI开发了一个大型的"单页面应用程序".当我在应用程序中加载各个部分时,它会创建jQuery UI小部件,如对话框或日期选择器.当我重新加载某些部分时,它们往往会徘徊并导致一些问题.我希望能够调用一个函数来销毁已加载的所有jQuery UI小部件并将其从DOM中删除.任何能够解决所有问题的解决方案?谢谢!
我需要在控制器中以编程方式获取已解决的错误消息.typeMismatch错误的默认验证消息不会从我的messages.properties文件中填充.我有一个表单支持对象,其中一个字段是一个整数.如果我为该字段提交字符串,我会得到:
Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'establishedYear'; nested exception is java.lang.NumberFormatException: For input string: "1995a"
Run Code Online (Sandbox Code Playgroud)
作为ObjectError中的默认消息.这是我输出的控制器:
@RequestMapping(method = RequestMethod.POST)
public @ResponseBody FormJSONResponse postForm(@Valid ProfileEditCompanyForm profileEditCompanyForm, BindingResult result) throws Exception {
if (result.hasErrors()) {
for (ObjectError objectError : result.getAllErrors()) {
System.out.println(objectError.getDefaultMessage()); // THIS IS NOT MY MESSAGE, BUT SHOULD BE
}
}
... other stuff ...
}
Run Code Online (Sandbox Code Playgroud)
所以我在WEB-INF/classes中添加了一个messages.properties,其中包含一些测试消息,看看是否可以覆盖该默认消息:
typeMismatch.profileEditCompanyForm.establishedYear=test 1
typeMismatch.establishedYear=test 2
typeMismatch.java.lang.Integer=test 3
typeMismatch=test 4
profileEditCompanyForm.establishedYear=test 5
establishedYear=test 6
Run Code Online (Sandbox Code Playgroud)
在我的app-servlet.xml文件中,我有:
<mvc:annotation-driven …
Run Code Online (Sandbox Code Playgroud) asp.net-core ×3
spring ×3
spring-mvc ×3
validation ×3
angular ×2
azure ×2
.net-core ×1
ajax ×1
asp.net ×1
asp.net-mvc ×1
c# ×1
hibernate ×1
html ×1
java ×1
javascript ×1
jquery ×1
jquery-ui ×1
jwt ×1
messages ×1
observable ×1
rxjs ×1