我有一个ELMAH问题.我认为这是连接字符串,但无法弄清楚原因.它通过电子邮件发送给我错误没问题,只是没有将它们记录到sql中.如果问题是权限,我如何捕获错误以向我显示其权限问题?以下是我的web.config的elmah相关部分:
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
<section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah" />
</sectionGroup>
Run Code Online (Sandbox Code Playgroud)
<connectionStrings>
<add name="ErrorLog" connectionString="Data Source=SQL1;Initial Catalog=ASBESTOS;User Id=MyUserName;Password=MyPassword" providerName="System.Data.SqlClient" />
Run Code Online (Sandbox Code Playgroud)
<system.web>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" …Run Code Online (Sandbox Code Playgroud) 我已经在.Net应用程序中使用Automapper和Autofac一段时间了.我这样配置它们:
builder.RegisterAssemblyTypes(typeof (OneOfMyMappingProfiles).Assembly)
.Where(t => t.IsSubclassOf(typeof (Profile)))
.As<Profile>();
builder.Register(ctx => new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers))
.AsImplementedInterfaces()
.SingleInstance()
.OnActivating(x =>
{
foreach (var profile in x.Context.Resolve<IEnumerable<Profile>>())
{
x.Instance.AddProfile(profile);
}
});
builder.RegisterType<MappingEngine>()
.As<IMappingEngine>().SingleInstance();
Run Code Online (Sandbox Code Playgroud)
使用最新版本的Automapper(4.2),API已发生变化,我无法转换为新的API.ConfigurationStore似乎不再存在.根据文档,注册IOC的方式现在是这样的:
var profiles =
from t in typeof (AutoMapperRegistry).Assembly.GetTypes()
where typeof (Profile).IsAssignableFrom(t)
select (Profile)Activator.CreateInstance(t);
var config = new MapperConfiguration(cfg =>
{
foreach (var profile in profiles)
{
cfg.AddProfile(profile);
}
});
For<MapperConfiguration>().Use(config);
For<IMapper>().Use(ctx => ctx.GetInstance<MapperConfiguration>().CreateMapper(ctx.GetInstance));
Run Code Online (Sandbox Code Playgroud)
但是那是使用StructureMap.上半部分没有问题,但我不知道如何翻译"For <>.Use()"部分.我如何在Autofac中做到这一点?
在Visual Studio 2015中进行调试期间,无法找到文件:
xxxx.cs not found
You need to find xxx.cs to view the source for the current call stack frame
Try one of the following options:
- Browse and find xxx.cs
You can view disassembly in the Dissasembly window. To alsways view dissassembly for the missing source files, change the setting in the Options dialog
Run Code Online (Sandbox Code Playgroud)
有问题的.cs文件来自第三方dll,因此我认为无法逐步执行该文件。似乎好像我不在调试中,但是我在web.config中。我已经在VS中尝试了一百万个设置,但似乎无济于事。例如:
取消选中“仅我的代码”复选框将文件添加到“不查找这些源文件”列表中使它停止询问文件在哪里,但是我仍然得到“找不到xxx.cs”选项卡
Optimizely CMS(艺术家以前称为EPiServer)最近发布了.Net Core版本。我可以使用 Kestrel 运行我的网站。但是,我想为我的网站设置一个特定的 url,并且我想为此 url 使用现有的 SSL 证书。
该证书安装在我的计算机上的 WebHosting 商店中。
这是我的 Kestrel 配置:
启动设置.json
"MySampleProject": {
"commandName": "Project",
"launchBrowser": true,
"externalUrlConfiguration": true,
"applicationUrl": "https://sampleproject.local.hostname.dev",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序设置.json
"Kestrel": {
"Endpoints": {
"HttpsInlineCertStore": {
"Url": "https://sampleproject.local.hostname.dev",
"Certificate": {
"Subject": "local.hostname.dev",
"Store": "WebHosting",
"Location": "LocalMachine",
"AllowInvalid": "true"
}
}
}
Run Code Online (Sandbox Code Playgroud)
在程序.cs中
public static IHostBuilder CreateHostBuilder(string[] args, bool isDevelopment)
{
return Host.CreateDefaultBuilder(args)
.ConfigureCmsDefaults()
.UseSerilog()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(serverOptions => serverOptions.AddServerHeader = false);
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging(logging => …Run Code Online (Sandbox Code Playgroud) 我在整理新的MailChimp API(V3.0)时遇到了麻烦.似乎没有办法调用订阅方法.好像我必须使用他们的注册表格.我对么?
我有一个webforms项目,但我正在使用WebAPI进行Web服务.我正在尝试实现Autofac.我正进入(状态:
'MyController' does not have a default constructor
Run Code Online (Sandbox Code Playgroud)
根据Autofac文档,我的配置正确,但显然存在问题.我使用的是Visual Studio 2010/.Net 4.这是我的Application_Start
private void Application_Start(object sender, EventArgs e)
{
//This enables api controllers in a separate class library
GlobalConfiguration.Configuration.Services.Replace(typeof(IAssembliesResolver), new AssembliesResolver());
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
//Elmah for webapi
GlobalConfiguration.Configuration.Filters.Add(new ElmahHandleErrorApiAttribute());
var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
var builder = new ContainerBuilder();
//Register DbContext
builder.RegisterType<MyDbContext>()
.As<IMyDbContext>()
.InstancePerRequest();
//Register service layer
var businessLayer = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies())
.Where(t => t.Name.EndsWith("Service"))
.AsImplementedInterfaces();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration);
var container = builder.Build();
_containerProvider = new ContainerProvider(container);
var …Run Code Online (Sandbox Code Playgroud) 我无法让automapper在我的单元测试中工作.我正在注入映射引擎,这在代码中工作正常,但不在测试中.这是我的测试设置和测试.我正在使用Moq来模拟映射引擎.
private static IDbContext Context { get; set; }
private static Mock<IMappingEngine> Mapper { get; set; }
private static Guid MenuId { get; set; }
private static Guid menuItem1Id { get; set; }
private static Guid menuItem2Id { get; set; }
private static Guid menuItem3Id { get; set; }
[ClassInitialize]
public static void SetUp(TestContext context)
{
MenuId = Guid.NewGuid();
Context = new TestDbContext();
menuItem1Id = Guid.NewGuid();
menuItem2Id = Guid.NewGuid();
menuItem3Id = Guid.NewGuid();
var contentPage1 = new ContentPage { Id = …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个dotnet新模板的NuGet包。我创建了一个nuspec文件来设置软件包的详细信息,它位于我的内容文件夹旁边,其中包含我想要打包的所有内容:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- The identifier that must be unique within the hosting gallery -->
<id>My.EpiserverCMS</id>
<!-- The package version number that is used when resolving dependencies -->
<version>1.0.0</version>
<!-- Authors contain text that appears directly on the gallery -->
<authors>Me</authors>
<description></description>
<!--
Owners are typically nuget.org identities that allow gallery
users to easily find other packages by the same owners.
-->
<owners>me</owners>
<!-- License and project URLs provide links for the gallery -->
<licenseUrl></licenseUrl> …Run Code Online (Sandbox Code Playgroud) asp.net ×3
autofac ×2
automapper ×2
c# ×2
.net ×1
asp.net-mvc ×1
dotnet-cli ×1
elmah ×1
kestrel ×1
mailchimp ×1
nuspec ×1
sql-server ×1
unit-testing ×1
web-config ×1