我已将elmah添加到asp.net mvc 4应用程序中.日志记录正在运行,现在我正在尝试配置安全性,但elmah没有获取设置,所有用户仍然可以看到日志.
这是一个内部网应用程序,因此我们使用windows集成secuirty.我正在尝试限制访问权限,以便只有domain\log_readers广告组的成员才能读取日志.
我在这里阅读了设置指南:http://code.google.com/p/elmah/wiki/SecuringErrorLogPages,我还阅读了SO和其他论坛上的几篇帖子,这些帖子让我添加了roleManager和WindowsRoleProvider配置一切都无济于事.
这是我的web.config的elmah部分:
<elmah>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on remote access and securing ELMAH.
-->
<security allowRemoteAccess="true" />
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/Logs" />
</elmah>
<location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<authentication mode="Windows" />
<roleManager defaultProvider="WindowsProvider"
enabled="true" cacheRolesInCookie="false">
<providers>
<add
name="WindowsProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on using ASP.NET authorization securing ELMAH.
-->
<authorization>
<allow roles="domain\log_readers"/>
<deny users="*" />
</authorization>
</system.web> …Run Code Online (Sandbox Code Playgroud) 我正在尝试验证从 azure 活动目录获得的访问令牌。
The I obtained the token from https://login.microsoftonline.com/{{my tennant guid}}/v2.0
however the issuer in the token that comes back is https://sts.windows.net//{{my tennant guid}}/ which doent match.
If I check that config at .well-known/openid-configuration the issuer is as expected https://login.microsoftonline.com/....
I've found a similar issue reported on git hub here https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/560
the outcome from this is to manually edit the manifest json in the application registration in AAD and set "accessTokenAcceptedVersion": 2
I've done this but …
我有一个返回 pdf 文件的 api。我试图在 vue.js 中显示它,并发现 vue-pdf 组件看起来应该可以完成这项工作。 这是github上的项目
我可以调用 API 并获取二进制响应,但无法将二进制数据转换为 vue-pdf 库可以显示的内容。
我的 vue 代码如下,其中注释掉了一些失败的尝试。
<template>
<pdf :src="pdfsrc"></pdf>
</template>
<script>
import pdf from "vue-pdf";
import axios from "axios";
export default {
components: {
pdf
},
data() {
return {
pdfsrc: null
};
},
created() {
return axios
.get(`${process.env.VUE_APP_API_INTRANET}/pdf`, {
responseType: "application/pdf"
})
.then(response => {
console.log("Success", response);
// 1
// this.pdfsrc = new Blob([response.data]);
// 2
//this.pdfsrc = response.data;
//3
// for (var i = 0; …Run Code Online (Sandbox Code Playgroud) 我在asp.net web api项目中使用ninject并且已经开始接收这个间歇性的ninject错误:
" 加载Ninject组件时出错ICache没有在内核的组件容器中注册这样的组件. "
我正在使用:
他们都被带入了我的项目,NuGet我在IocConfig.RegisterIoc中加载我的模块,并没有做任何其他更改或调整.
它可能是不相关的,但问题开始发生在我开始将IKernel注入我的一个构造函数的同时.关于"特殊解析器",我没有为此设置约束.
我在这里已经阅读了许多类似的问题:
Ninject +"加载Ninject组件ICache时出错"
MVC3项目中的Ninject和ChildKernel:"加载Ninject组件ICache时出错"
随机发生的Ninject异常:"加载Ninject组件ICache时出错"
虽然在每种情况下OP都有与我相同的错误,但解决方案并不合适 - 我没有创建子内核,而且我没有使用ninject的错误版本.
我正在尝试使用elmah从我的asp.net web api项目中记录异常.我有一个问题,每个错误被记录两次.
我正在使用Elmah.Contrib.Web-Api和我的Application类如下:
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configuration.Filters.Add(new ElmahHandleErrorApiAttribute());
RouteTable.Routes.MapHubs();
RouteConfig.RegisterRoutes(RouteTable.Routes);
#if DEBUG
EntityFrameworkProfiler.Initialize();
#endif
GlobalConfig.CustomizeConfig(GlobalConfiguration.Configuration);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我提出以下行,那么我根本就没有消息:
GlobalConfiguration.Configuration.Filters.Add(new ElmahHandleErrorApiAttribute());
Run Code Online (Sandbox Code Playgroud)
我可以确认我只抛出一个错误,产生错误的调用只被调用一次而且我没有用Elmah属性手动修饰我的控制器或方法.
为了尝试解决这个问题,我删除了Contrib包,并按照此处的说明添加了http://www.tugberkugurlu.com/archive/asp-net-web-api-and-elmah-integration
这没有解决问题,它仍然记录两次.它确实允许我在Attribute类中加入一个断点,并确认每次错误都会被调用两次.
我怎么解决这个问题?
我有一些映射代码如下
Mapper.CreateMap<CalculationQueryResult, CalculationViewModel>()
.ForMember(poco => poco.NomineeFee,
opt => opt.ResolveUsing<FormattedCurrencyInt>()
.FromMember(m => m.NomineeFee))
.ForMember(poco => poco.TotalContributions,
opt => opt.ResolveUsing<FormattedCurrencyInt>()
.FromMember(m => m.TotalContributions))
.ForMember(poco => poco.EquityInjection,
opt => opt.ResolveUsing<FormattedCurrencyInt>()
.FromMember(m => m.EquityInjection))
// ... SNIP Lots more members mapped with Formatted Currency Resolver
Run Code Online (Sandbox Code Playgroud)
如您所见,我使用相同的解析器映射多个成员,以将整数转换为格式化的货币字符串.我正在为绝大多数人这样做,但不是我的poco课上的所有成员.
如果我不需要继续重复这些类型,那么所有这些成员都将使用基于约定的映射进行映射.它为大量的任务编写了大量的代码.
是否有任何方法可以覆盖将int转换为单个映射的字符串的默认行为,然后执行自定义.ForMembers,我想要一些不同的东西.比如这样:
Mapper.CreateMap<CalculationQueryResult, CalculationViewModel>()
.SetDefault<int,string>(opt => opt.ResolveUsing<FormattedCurrencyInt>())
.ForMember(poco => poco.Count, x=>x.MapFrom(s => s.Count.ToString()));
Run Code Online (Sandbox Code Playgroud) 我正在使用 MSAL.js 作为 Azure Active Directory 的客户端构建 javascript SPA。
为我的 API 请求访问令牌时
var requestObj = {
scopes: ["api://MyApi/Access"]
};
msalUserAgent.acquireTokenSilent(requestObj )
Run Code Online (Sandbox Code Playgroud)
Msal 在内部创建了一个 iframe 来处理请求,然后给出以下关于在不支持的 iframe 内操作的错误:
ClientAuthError: Token calls are blocked in hidden iframes
at ClientAuthError.AuthError [as constructor] (webpack-internal:///./node_modules/msal/lib-es6/error/AuthError.js:26:28)
at new ClientAuthError (webpack-internal:///./node_modules/msal/lib-es6/error/ClientAuthError.js:111:28)
at Function.ClientAuthError.createBlockTokenRequestsInHiddenIframeError (webpack-internal:///./node_modules/msal/lib-es6/error/ClientAuthError.js:192:16)
at Function.WindowUtils.blockReloadInHiddenIframes (webpack-internal:///./node_modules/msal/lib-es6/utils/WindowUtils.js:206:90)
at eval (webpack-internal:///./node_modules/msal/lib-es6/UserAgentApplication.js:474:77)
at new Promise (<anonymous>)
at UserAgentApplication.acquireTokenSilent (webpack-internal:///./node_modules/msal/lib-es6/UserAgentApplication.js:472:16)
at Object.ensureUserLoggedIn (webpack-internal:///./src/services/ActiveDirectoryService.js:93:19)
at eval (webpack-internal:///./src/main.js:36:89)
at Module../src/main.js (http://localhost:8080/js/app.js:1178:1)
Run Code Online (Sandbox Code Playgroud)
我的网页似乎仍然按预期工作,但我真的不习惯携带未解决的错误,所以我试图找出问题的原因。
在尝试解决这个问题时,我在 github 上发现了这个问题, 它看起来很像我的问题。它确认acquireTokenSilent 确实创建了一个iFrame,该iFrame 重定向回主spa 应用程序(然后尝试登录并请求令牌......所以基本上是无限递归)。这就是它被阻止的原因。
建议之一是将 redirectUri …
我正在编写一个简单的任务运行器应用程序.
我有一堆实现ITask接口的类:
public interface ITask
{
void Run();
}
Run Code Online (Sandbox Code Playgroud)
我正在编写一个简单的控制台应用程序来创建ITasks实例,然后在每个应用程序上调用Run().任务实现使用构造函数注入,所以我想使用ninject.
我希望能够在运行时指定要运行哪些任务以及因此要激活哪些ITask实现.
我想我可以将具体类型放入我的app.config然后在运行时我可以获得ninject从中构建一个ITask数组.如果做不到这一点,我可以指定我想在命令行上运行的任务.
对我来说,这听起来像ninject的一个相当直接的案例,但我一直无法找到如何从配置或字符串绑定ninject.
任何人都能指出我正确的方向吗?
我有一个TeamCity(8.0.5)设置,运行多个代理和多个配置多个项目.
我们有一些CI的构建配置(例如编译和单元测试)和一些用于自动部署的配置.
部署配置在共享服务(例如IIS/sql等)上运行脚本,因此无法与任何项目中的其他部署版本并行运行.
在团队城市有没有办法限制这个?
我已经看到设置为"限制并发构建",但这仅适用于单个配置,我也尝试将部署构建限制为单个公共代理,但到目前为止我还没能做到这一点.
我正在使用简单的注射器3.0.4
我有一种服务,其生活方式取决于具有短暂生活方式的服务.
当我调用container.Verify()时,我得到一个关于生活方式不匹配的诊断错误.
导致问题的瞬态服务被注入到其他临时服务中,所以在我开始使用整个项目范围之前我需要问一下.为什么从任何生活方式的范围到短暂的依赖都是一个问题?每次注射瞬态时都会新鲜出现,所以没有其他任何东西可以干扰它.本质上,瞬态对象的生命周期由它注入的服务控制.
此外,我已经从这里阅读了有关此主题的文档,并且我确实理解为什么您不希望单例依赖于作用域服务,但是对瞬态的依赖总是安全的?
asp.net-mvc ×2
azure ×2
c# ×2
elmah ×2
javascript ×2
ninject ×2
.net ×1
asp.net ×1
automapper ×1
pdf ×1
pdf.js ×1
security ×1
teamcity ×1
teamcity-8.0 ×1
vue-pdf ×1
vue.js ×1