Serilog - Configuring Multiple Sinks in AppSettings - serilog

I am trying to wire-up serilog using the app settings package and when I run my program Serlog is complaining it cannot find the RollingFile assembly. I did not have this problem using a single sink but multiple it giving me fits:
<!-- Serilog Configuration -->
<add key="serilog:using:Email" value="Serilog.Sinks.Email" />
<add key="serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />
<!-- Configure Serilog Email Sink -->
<add key="serilog:write-to:Email"/>
<add key="serilog:write-to:Email.mailServer" value="***" />
<add key="serilog:write-to:Email.toEmail" value="***" />
<add key="serilog:write-to:Email.fromEmail" value="***" />
<add key="serilog:write-to:Email.mailSubject" value="Notification" />
<add key="serilog:write-to:Email.restrictedToMinimumLevel" value="Debug" />
<!-- Configure Serilog RollingFile Sink -->
<add key="serilog:write-to:RollingFile" />
<add key="serilog:write-to:RollingFile.restrictedToMinimumLevel" value="Debug" />
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\comply360-user-mgmt-{Date}.txt" />
<add key="serilog:write-to:RollingFile.outputTemplate" value="{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] [{CorrelationId}] {Message}{NewLine}{Exception}" />

You have to use prefix in web.config and in Configuration like this
Web.Config
<!-- Serilog Configuration -->
<add key="email:serilog:using:Email" value="Serilog.Sinks.Email" />
<add key="file:serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />
<!-- Configure Serilog Email Sink -->
<add key="email:serilog:write-to:Email"/>
<add key="email:serilog:write-to:Email.mailServer" value="***" />
<add key="email:serilog:write-to:Email.toEmail" value="***" />
<add key="email:serilog:write-to:Email.fromEmail" value="***" />
<add key="email:serilog:write-to:Email.mailSubject" value="Notification" />
<add key="email:serilog:write-to:Email.restrictedToMinimumLevel" value="Debug" />
<!-- Configure Serilog RollingFile Sink -->
<add key="file:serilog:write-to:RollingFile" />
<add key="file:serilog:write-to:RollingFile.restrictedToMinimumLevel" value="Debug" />
<add key="file:serilog:write-to:RollingFile.pathFormat" value="C:\Logs\comply360-user-mgmt-{Date}.txt" />
<add key="file:serilog:write-to:RollingFile.outputTemplate" value="{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] [{CorrelationId}] {Message}{NewLine}{Exception}" />
Startup.cs
Log.Logger = new LoggerConfiguration()
.ReadFrom
.AppSettings("email")
.ReadFrom
.AppSettings("file")
.CreateLogger()

figured it out. i had to remove the rolling file using statement.

Related

IIS Rewrite, with the swagger ui giving 404 not found error

I am hosting Dotnet Core 3.1 project with a Vue js application. For that, I have hosted the vue js static files inside the www-root folder.
I also have a swagger UI in my application.
This is the default web config that I have in the hosted directory.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
With this configuration, the swagger ui runs fine without any error.
But I have to add the rewrite logic for the Vue js application, so I have updated the web config with the following configuration.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="wwwroot-static" stopProcessing="true">
<match url="([\S]+[.](html|htm|svg|js|css|png|gif|jpg|jpeg))" />
<action type="Rewrite" url="wwwroot/{R:1}" />
</rule>
<rule name="empty-root-index" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="wwwroot/index.html" />
</rule>
<!--
Make sure you have a <base href="/" /> tag to fix the root path
or all relative links will break on rewrite
-->
<rule name="AngularJS-Html5-Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/.well-known/openid-configuration" negate="true" />
<add input="{REQUEST_URI}" pattern="^/.well-known/jwks" negate="true" />
<add input="{REQUEST_URI}" pattern="^/api(.*)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/swagger(.*)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/account(.*)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/connect(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="wwwroot/index.html" />
</rule>
</rules>
</rewrite>
<handlers>
<add name="StaticFileModuleHtml" path="*.htm*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFileModuleSvg" path="*.svg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFileModuleJs" path="*.js" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFileModuleCss" path="*.css" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFileModuleJpeg" path="*.jpeg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFileModuleJpg" path="*.jpg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFileModulePng" path="*.png" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="StaticFileModuleGif" path="*.gif" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
With this configuration in the web config, my vue js application runs fine. But then when I go the site: http(s)://[MYWEBAPP]/swagger, it redirects to http(s)://[MYWEBAPP]/swagger/index.html and gives a 404 files not found error.
Configure Service in my startup class looks like this:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseSwagger();
app.UseSwaggerUI(c =>
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Sample API")
);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
Trying through the multiple available solutions, I realized that the swagger UI is trying to look for the index.html from the wwwroot, so it is causing the not found error. I am stuck on how to suggest swagger UI to look into the own directory.
What could be the issues with this? What am i missing here? Anyone else also might have this issue?

How can I hook up custom email provider in ELMAH?

I've asked this on the elmah group in google groups but am still mystified so I thought I'd throw it out to a larger pool. Here's the original note with my code as it currently stands.
I have ELMAH set up on my MVC 5 application and I want to use a custom email service to send email instead of using the smtp send that is set up by default. (This is an organizational preference.) I've been poking around at it but can't figure out how to do this. My service call is working just fine, but I can't hook it up so that it runs when there is an exception. Any assistance will be greatly appreciated.
What I've got set up is the following:
Web.config (removed non-elmah-related lines):
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<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" />
</sectionGroup>
</configSections><appSettings>
...
<add key="elmah.mvc.disableHandler" value="false" />
<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
<add key="elmah.mvc.requiresAuthentication" value="false" />
<add key="elmah.mvc.IgnoreDefaultRoute" value="false" />
<add key="elmah.mvc.allowedRoles" value="*" />
<add key="elmah.mvc.allowedUsers" value="*" />
<add key="elmah.mvc.route" value="elmah" />
</appSettings>
<connectionStrings>
<add name="BFRDPDB" providerName="System.Data.SqlClient" connectionString="blahblah;" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<customErrors mode="Off" defaultRedirect="~/Home/Error">
<error statusCode="404" redirect="~/Home/Error" />
</customErrors>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="BFRDP.Infrastructure.ErrorMailModule" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="BFRDP.Infrastructure.ErrorMailModule" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
</system.webServer>
<elmah>
<security allowRemoteAccess="false" />
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="BFRDPDB"
applicationName="FarmAnswers.org" />
</elmah>
<location path="elmah">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD"
path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<authorization>
<allow roles="SuperAdmin" />
<deny users="*" />
</authorization>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH"
verb="POST,GET,HEAD"
path="elmah"
type="Elmah.ErrorLogPageFactory, Elmah"
preCondition="integratedMode" />
</handlers>
</system.webServer>
</location>
</configuration>
And my ErrorMailModule.cs file looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
namespace BFRDP.Infrastructure
{/// <summary>
/// Summary description for ErrorMailModule
/// </summary>
public class ErrorMailModule : Elmah.ErrorMailModule
{
public ErrorMailModule()
{
}
protected override void SendMail(MailMessage mail)
{
if (mail == null)
throw new ArgumentNullException("mail");
// Code to send email here through internal provider
}
}
}
My error is indeed logged in the database, but the code to send the email is never reached.
What am I doing wrong?
Added the errorMail settings in the section of my web.config and the app was able to get to my custom module:
<elmah>
<security allowRemoteAccess="false" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="BFRDPDB" applicationName="FarmAnswers.org" />
<errorMail
from="elmah#example.com"
to="admin#example.com"
subject="..."
priority="Low"
async="true"
smtpPort="25"
smtpServer="smtp.example.com"
useSsl="true"
userName="johndoe"
password="secret"
noYsod="true" />
</elmah>

argumentexception was unhandled by user code asp.net mvc

I having trouble with pro asp.net mvc 5 book by Adam Freeman. When I try to start debugging, I catch the error:
An exception of type 'System.ArgumentException' occurred in System.Data.dll but was not handled in user code Additional information: Keyword not supported: 'initialcatalog'.But my Web.config not such as in the book.
Screen:[1]: http://imgur.com/3TpOL0E
My Web.config code:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="EFDbContext" connectionString="Data Source=(localdb)\v11.0; InitialCatalog=SportsStore; Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
P.S. Sorry my google translate English.
Try adding a space in the connection string like so:
Initial Catalog=SportsStore;

Images, CSS, and JS Not Loading in MVC4 App

I just deployed a new MVC4 app to my server and some of the CSS, JS, and images are not loading. For example, the Chrome console says,
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
http://beta.vinformative.com/Content/themes/base/jquery-ui-1.8.20.custom.css
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
http://beta.vinformative.com/Content/select2.css
Failed to load resource: the server responded with a status of 500 (Internal Server
Error) http://beta.vinformative.com/Scripts/Plugins/select2.js
Failed to load resource: the server responded with a status of 500 (Internal
Server Error) http://beta.vinformative.com/Scripts/WineCreate.js
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
http://beta.vinformative.com/Content/images/logo_revisedsmall.png
They are all available on server in the locations they mention. I've been troubleshooting other things all night, so I'm a little blurry eyed and maybe I'm missing something obvious. You can see these errors right on the homepage at beta.vinformative.com as well.
Here is a screenshot of my file layout too from the server:
I am using bundling and published the site to file system in release mode, but I wouldn't expect that to effect the images, would it? I'm going to keep at this, but any help would be greatly appreciated! Thanks!
EDIT as requested bundle config: THANKS!
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/Libraries/jquery-{version}.js",
"~/Scripts/Plugins/jquery.loaderbutton.js",
"~/Scripts/Plugins/jquery.form.js"));
bundles.Add(new ScriptBundle("~/bundles/base").Include(
"~/Scripts/Feedback.js",
"~/Scripts/Global.js",
"~/Scripts/WineSearch.js"
));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/Libraries/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/Libraries/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap/bootstrap.js",
"~/Scripts/bootstrap/bootbox.js",
"~/Scripts/bootstrap/bootstrap-notify.js"
));
bundles.Add(new ScriptBundle("~/bundles/formhelpers").Include(
"~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-countries.js",
"~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-countries.en_US.js",
"~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-phone.js",
"~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-phone.format.js",
"~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-states.js",
"~/Scripts/bootstrap/Form Helpers/bootstrap-formhelpers-states.en_US.js"
));
bundles.Add(new ScriptBundle("~/bundles/winedetails").Include(
"~/Scripts/WineDetails.js",
"~/Scripts/Plugins/jquery.uploadifive.js",
"~/Scripts/Plugins/jquery.fileDownload.js",
"~/Scripts/Plugins/jquery.fancybox.js",
"~/Scripts/Plugins/jquery.fancybox-media.js",
"~/Scripts/Plugins/jquery.nailthumb.1.1.js",
"~/Scripts/Plugins/jquery.lazyload.js"
));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css", "~/Content/slideout.css"));
bundles.Add(new StyleBundle("~/Content/themes/bootstrap/css").Include(
"~/Content/themes/bootstrap/bootstrap.css",
"~/Content/themes/bootstrap/bootstrap-responsive.css",
"~/Content/themes/bootstrap/bootstrapSwitch.css",
"~/Content/themes/bootstrap/bootstrap-notify.css",
"~/Content/themes/bootstrap/bootstrap-formhelpers.css"
));
bundles.Add(new StyleBundle("~/Content/datatables").Include(
"~/Content/jquery.dataTables.css",
"~/Content/jquery.dataTables_themeroller.css"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/chosen.css"));
bundles.Add(new StyleBundle("~/Content/sitewide").Include(
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/Site.css"
));
bundles.Add(new StyleBundle("~/Content/winedetails").Include(
"~/Content/uploadifive.css",
"~/Content/themes/fancybox/jquery.fancybox.css"
));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.slider.css",
"~/Content/themes/base/jquery.ui.tabs.css",
"~/Content/themes/base/jquery.ui.datepicker.css",
"~/Content/themes/base/jquery.ui.progressbar.css",
"~/Content/themes/base/jquery.ui.theme.css"));
}
}
EDIT # 2
I tried to change my reference in my _layout view with no luck:
from
<link href="../../Content/themes/base/jquery-ui-1.8.20.custom.css" rel="stylesheet"
to
<link href="#Url.Content("~/Content/themes/base/jquery-ui-1.8.20.custom.css")" rel="stylesheet">
EDIT #3 Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core">
<section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" />
<section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" />
<section name="openid" type="DotNetOpenAuth.Configuration.OpenIdElement, DotNetOpenAuth.OpenId" requirePermission="false" allowLocation="true" />
<section name="oauth" type="DotNetOpenAuth.Configuration.OAuthElement, DotNetOpenAuth.OAuth" requirePermission="false" allowLocation="true" />
</sectionGroup>
<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" />
</sectionGroup>
<section name="web.optimization" type="Web.Optimization.Configuration.OptimizationSection" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="Elmah" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=elmah;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="vfContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=vf3;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<customErrors mode="On" defaultRedirect="~/Error/Generic">
<error statusCode="404" redirect="~/Error/NotFound" />
<error statusCode="500" redirect="~/Error/internal" />
</customErrors>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<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>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
<mimeMap fileExtension=".ogg" mimeType="video/ogg" />
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
<mimeMap fileExtension=".oga" mimeType="audio/ogg" />
<mimeMap fileExtension=".spx" mimeType="audio/ogg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
<remove fileExtension=".manifest" />
<mimeMap fileExtension=".manifest" mimeType="text/cache-manifest" />
</staticContent>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="RazorEngine" publicKeyToken="9ee697374c7e744a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.8.0" newVersion="3.0.8.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
</assemblyBinding>
<legacyHMACWarning enabled="0" />
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<system.net>
<defaultProxy enabled="true" />
<mailSettings>
<smtp from="mailer#vinformative.com">
<network host="smtp.emailsrvr.com" port="2525" userName="mailer#vinformative.com" password="vinf0rmat1ve" />
</smtp>
</mailSettings>
<settings>
<!-- This setting causes .NET to check certificate revocation lists (CRL)
before trusting HTTPS certificates. But this setting tends to not
be allowed in shared hosting environments. -->
<!--<servicePointManager checkCertificateRevocationList="true"/>-->
</settings>
</system.net>
<dotNetOpenAuth>
<messaging>
<untrustedWebRequest>
<whitelistHosts>
<!-- Uncomment to enable communication with localhost (should generally not activate in production!) -->
<!--<add name="localhost" />-->
</whitelistHosts>
</untrustedWebRequest>
</messaging>
<!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
<reporting enabled="true" />
<openid>
<relyingParty>
<security requireSsl="false">
<!-- Uncomment the trustedProviders tag if your relying party should only accept positive assertions from a closed set of OpenID Providers. -->
<!--<trustedProviders rejectAssertionsFromUntrustedProviders="true">
<add endpoint="https://www.google.com/accounts/o8/ud" />
</trustedProviders>-->
</security>
<behaviors>
<!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible
with OPs that use Attribute Exchange (in various formats). -->
<add type="DotNetOpenAuth.OpenId.RelyingParty.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth.OpenId.RelyingParty" />
</behaviors>
</relyingParty>
</openid>
</dotNetOpenAuth>
<uri>
<!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names),
which is necessary for OpenID urls with unicode characters in the domain/host name.
It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. -->
<idn enabled="All" />
<iriParsing enabled="true" />
</uri>
<elmah>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on remote access and securing ELMAH.
-->
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="Elmah"></errorLog>
<errorMail from="mailer#vinformative.com" to="support#vinformative.com" subject="ELMAH Error Log Mail"></errorMail>
<security allowRemoteAccess="false" />
</elmah>
<location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<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="admin" />
<deny users="*" />
</authorization>
-->
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
</location>
<web.optimization>
<bundles>
<bundle virtualPath="~/Content/sample" transform="System.Web.Optimization.JsMinify, System.Web.Optimization">
<content>
<!-- Add some single files -->
<!-- <add path="~/Scripts/validation.js" /> -->
<!-- <add path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js" /> -->
<!-- Add a directory (and its subdirectories) -->
<!-- <add path="~/Scripts/Plugins" searchPattern="*.js" searchSubdirectories="true" /> -->
</content>
<!--
If you want to apply multiple transformations,
you should remove the "transform" attribute from the bundle.
-->
<!--
<transformations>
<add type="Web.Optimization.Bundles.CoffeeScript.CoffeeScriptTransform, Web.Optimization.Bundles.CoffeeScript" />
<add type="System.Web.Optimization.JsMinify, System.Web.Optimization" />
</transformations>
-->
</bundle>
</bundles>
</web.optimization>
</configuration>
Only non-bundled CSS and JS and img tags are not rendering.
FIXED!
I commented out the following in my node:
<staticContent>
<!-- <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
<mimeMap fileExtension=".ogg" mimeType="video/ogg" />
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
<mimeMap fileExtension=".oga" mimeType="audio/ogg" />
<mimeMap fileExtension=".spx" mimeType="audio/ogg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />-->
<remove fileExtension=".manifest" />
<mimeMap fileExtension=".manifest" mimeType="text/cache-manifest" />
</staticContent>
Comment out this under system.webserver in web.config
<staticContent>
<!-- <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
<mimeMap fileExtension=".ogg" mimeType="video/ogg" />
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
<mimeMap fileExtension=".oga" mimeType="audio/ogg" />
<mimeMap fileExtension=".spx" mimeType="audio/ogg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />-->
<remove fileExtension=".manifest" />
<mimeMap fileExtension=".manifest" mimeType="text/cache-manifest" />
</staticContent>
I added app.UseStaticFiles(); this code in starup.cs of Configure method, than it is fixed.
My fix ended up being to rename my solution file and delete a directory found under the ".vs" folder. Issue precursors - Using VS2019, I created an ASP.NET Core app that had the same name as my solution file. I had meant to create a full-framework asp.net project and so I removed/deleted the ASP.NET Core project from the solution and created a new full-framework with the same name. I believe this caused IIS Express to continue using some of the remnant configuration found under the ".vs\" folder that was telling it to use some ASP.NET Core modules.
This worked for me:
Close Visual Studio
Change my solution name to something different from my web project name
Remove the directory described above that was under the .vs folder
Reopen Visual Studio and run the web project

ELMAH - MVC 3 - 403 - Forbidden: Access is denied

I have installed Elmah for MVC using NuGet, I'am able to login with success error in the db.
The only problem is that I cannot access the /elmah URL to access the Error Log Page.
Here part of my configuration, could you please point out if I have any misconfiguration?
Thanks
ERROR
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
In my web.config:
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="elmah.mvc.disableHandler" value="false" />
<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
<add key="elmah.mvc.requiresAuthentication" value="true" />
<add key="elmah.mvc.allowedRoles" value="Administrator" />
<add key="elmah.mvc.route" value="elmah" />
</appSettings>
In global.asax:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("elmah.axd");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
(This is all from the documentation/getting started)
You don't need the following line:
routes.IgnoreRoute("elmah.axd");
The next line takes care of it.
Everything you need to configure is in your web.config file. Something like:
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="mySqlConnString" />
</elmah>
<location path="elmah.axd">
<system.web>
<authorization>
<allow roles="Administrator" />
<deny users="*" />
</authorization>
</system.web>
</location>
Should get you going.
Just in case anyone comes across the same issue I had.
This was my code, which is wrong:
<elmah>
<security allowremoteAccess="true" />
</elmah>
The issue was the r in allowremoteAccess, it was in lower case, when it should have been upper-case!
Correct code:
<elmah>
<security allowRemoteAccess="true" />
</elmah>
Even though I had added the remote access to my web.config:
<add key="elmah.mvc.allowedRoles" value="adminrole" />
<elmah>
<security allowRemoteAccess="true" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="DefaultConnection" />
</elmah>
I had to edit Elmah.Athz.config on the server and add the role I wanted to give access to elmah. I had to add ^adminrole

Resources